안녕세계
[안드로이드] Splash - 앱 로딩 화면 본문
[안드로이드] Splash - 앱 로딩 화면
Junhong Kim 2017. 3. 20. 19:49728x90
반응형
1. XML 파일 생성
[res/layout/activity_splash.xml]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:padding="20dp"
android:src="@drawable/icon_logo" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_white"
android:orientation="horizontal"
android:padding="5dp">
<TextView
style="@style/LargeFont"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bucket"
android:textColor="@color/colorPrimary"
android:textStyle="bold" />
<TextView
style="@style/LargeFont"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" List"
android:textColor="@color/colorPrimary" />
</LinearLayout>
</LinearLayout>
<TextView
style="@style/SmallFont"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Copyright © 2017 Junhong-Kim. All rights reserved."
android:textColor="#ffffff" />
</LinearLayout>
2. Java 파일 생성
[java/SplashActivity]
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(getApplicationContext(), MainActivity.class));
finish();
}
}, 2000);
}
}
3. AndroidMainfest에 activity 추가 및 intent-filter 정의
[manifests/AndroidManifest.xml]
<activity android:name=".activity.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
728x90
반응형
'Client > Android' 카테고리의 다른 글
[안드로이드] ImageView에 image url로 이미지 지정 (0) | 2017.06.13 |
---|---|
[안드로이드] .apk 파일 추출 (배포용, 테스트용) (0) | 2017.06.12 |
[안드로이드] Toolbar (0) | 2017.01.17 |
[안드로이드] RecyclerView - Divider 생성 (0) | 2017.01.16 |
[안드로이드] RecyclerView With TabLayout (Feat. ViewPager) (0) | 2017.01.12 |
Comments