안드로이드 Splash Activity (어플 설명 액티비티, 어플 대표 화면) 만들기 :: 안드로이드 설치 및 개발[SSISO Community]
 
SSISO 카페 SSISO Source SSISO 구직 SSISO 쇼핑몰 SSISO 맛집
추천검색어 : JUnit   Log4j   ajax   spring   struts   struts-config.xml   Synchronized   책정보   Ajax 마스터하기   우측부분

안드로이드 설치 및 개발
[1]
등록일:2018-10-22 15:30:09 (0%)
작성자:
제목:안드로이드 Splash Activity (어플 설명 액티비티, 어플 대표 화면) 만들기

카카오톡 실행시켜보면

처음에 카카오톡 이미지가 나오고 1초뒤에 카톡이 실행됩니다.

 

어플리케이션의 대표 레이아웃을 넣어 어플리케이션의 이미지를 담당하는 액티비티입니다.

 

 

만드는 방법은 간단합니다.

 

프로젝트 생성에 Default MainActivity.class 를 Splash로 변경합니다.

 

 

다음 설정은 기호에 맞게 설정하시면됩니다.

 

 

 

이 화면에서 Activity name 을 Splash라 하겠습니다.

 

 

 

 

 

프로젝트가 생성되자마자 기본으로 생성된 패키지 내에 MainPage 클래스를 생성합니다.

 

 

 

Splash 레이아웃도 하나 만들어줘야겠죠?

만들어줍니다.

 

 

 

Splash로 사용할 대표 이미지를 넣어줍니다.

 

자 이제 준비가 끝났습니다.

 

코드를 작성해볼까요?

 

 

 

Splash.class

 


import android.app.Activity;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.WindowManager;

public class Splash extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_splash);

Handler hd = new Handler();
hd.postDelayed(new splashhandler(), 3000); // 1초 후에 hd handler 실행 3000ms = 3초

}

private class splashhandler implements Runnable{
public void run(){
startActivity(new Intent(getApplication(), MainPage.class)); //로딩이 끝난 후, ChoiceFunction 이동
Splash.this.finish(); // 로딩페이지 Activity stack에서 제거
}
}

@Override
public void onBackPressed() {
//초반 플래시 화면에서 넘어갈때 뒤로가기 버튼 못누르게 함
}

}

 

 

MainPage.class

import android.app.Activity;
import android.os.Bundle;

/**
* Created by YooJongHyeok on 2017-07-13.
*/

public class MainPage extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

 

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="@drawable/splash">

</LinearLayout>

 

 

activity_main.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:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="메인 페이지입니다." />

</LinearLayout>

 

 

 

중요한것! 액티비티를 주가하면

매니페스트에 정의 해주어야합니다.

 

 

manifests.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jy.splash">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".Splash"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".MainPage"/> <!--이부분 추가-->

</application>
</manifest>

어플리케이션 실행해볼까요?

 

 

 

 

쨘~ 수고하셨습니다.



출처: http://yoo-hyeok.tistory.com/31?category=708422 [유혁의 엉터리 개발]
[본문링크] 안드로이드 Splash Activity (어플 설명 액티비티, 어플 대표 화면) 만들기
[1]
코멘트(이글의 트랙백 주소:/cafe/tb_receive.php?no=34888
작성자
비밀번호

 

SSISOCommunity

[이전]

Copyright byCopyright ⓒ2005, SSISO Community All Rights Reserved.