개발 /우리 지금 만나
Android App For Mac 제작 (8) - 인트로 화면 만들기
hoon222y
2017. 12. 1. 17:02
보통 대부분의 어플이 처음 시작될때는 인트로 화면이 1~2초정도 등장하게 된다. 있어보이기 위해서 나 또한 인트로 화면을 넣게 되었다. 먼저 인트로 화면을 넣기 위해서는 intro Class와, intro xml이 있어야 하는것은 당연하다.
Intro_activity.class의 경우에는
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | package net.daum.android.map.openapi.sampleapp.demos; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.os.Handler; import net.daum.android.map.openapi.sampleapp.MainActivity; import net.daum.android.map.openapi.sampleapp.R; /** * Created by Hoony on 2017. 12. 1.. */ public class IntroActivity extends Activity { private Handler handler; Runnable runnable = new Runnable() { @Override public void run() { Intent intent = new Intent(IntroActivity.this, MainActivity.class); startActivity(intent); finish(); overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.intro_activity); init(); handler.postDelayed(runnable, 3000); } public void init() { handler = new Handler(); } @Override public void onBackPressed(){ super.onBackPressed(); handler.removeCallbacks(runnable); } } | cs |
이런식으로 그냥 가져다가 쓰면 아아아아주 편하당 ㅎㅎ... 나도 긁어왔다 .. 3000이라고 적혀있는 곳이 우리가 그 인트로 화면을 얼마나 띄울것인지 (밀리세컨드 단위이기 때문에 3000이면 3초간 나오는 것이다.)를 설정하는 곳이다.
XML은 알아서 잘 만드시면 될것 같고, 필수적으로 설정할 부분이 AndroidManifest.xml에서 activity를 추가할 때 Intent를 인트로를 넣는곳에 넣어주어야 한다는 것이다.
1 2 3 4 5 6 7 8 9 10 | <activity android:name=".demos.IntroActivity" android:label="@string/title_activity_intro" android:theme="@style/AppTheme.NoActionBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> | cs |
이런식으로 activity를 선언할 때 5~9번째 줄 코드를 넣어주면 원하는 인트로 화면이 잘 작동할 것이다.