- 정보공유
[안드로이드] 웹뷰로딩전 인트로 페이지 만들기.
- Intro.java
public class Intro extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.intro);
new Thread(new Runnable() {
public void run() {
// TODO Auto-generated method stub
try {
Thread.sleep(2000);
} catch (Throwable ex) {
ex.printStackTrace();
}
Intent i = new Intent(Intro.this, MainActivity.class);
startActivity(i);
finish();
}
}).start();
}
}Intent i = new Intent(Intro.this, MainActivity.class); 원래 처음 로딩되는 클래스를 넣어줍니다.
- intro.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/intro"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@mipmap/ic_launcher" >
</ImageView>
</LinearLayout>
android:src="@mipmap/ic_launcher" 부분은 인트로 이미지 경로를 넣습니다.
- Manifest.xml
<activity
android:name=".Intro"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.NoActionBar">
</activity>
웹뷰 이므로 android:theme="@style/Theme.AppCompat.NoActionBar" 가 추가되어있습니다.
MainActivity 에 해당하는 activity 가 intro activity 보다 밑에 있어야 나중에 실행이 됩니다.