2010-01-26
■Androidアプリでスプラッシュ画面を表示させる方法
やっと分かった!Androidアプリでスプラッシュ(Splash)画面を表示させる方法が!
今までググっても、「これだっ!」って情報が無かったんですが、今日買った「コードからわかるAndroidプログラミングのしくみ 開発で困ったときの解決アプローチ」という本に書いてありました。
というわけで、そのやり方を書いておきます。
Androidプロジェクトのなかで書き換える箇所は、以下の3つです。
- splash.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:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="centerInside" android:src="@drawable/logo" /> </LinearLayout>
- SplashActivity.java
public class SplashActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.splash); Handler hdl = new Handler(); hdl.postDelayed(new splashHandler(), 500); } class splashHandler implements Runnable { public void run() { Intent i = new Intent(getApplication(), MainActivity.class); startActivity(i); SplashActivity.this.finish(); } } }
- AndroidManifest.xmlの一部
<activity android:name=".SplashActivity" android:screenOrientation="portrait" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
トラックバック - http://d.hatena.ne.jp/yamamotodaisaku/20100126/1264504434
リンク元
- 14 http://twitter.com/
- 7 http://pipes.yahoo.com/pipes/pipe.info?_id=VD8z_WEU3RGV_22Tw5tC8g
- 5 http://hootsuite.com/dashboard
- 5 http://www.google.co.jp/reader/view/
- 4 http://reader.livedoor.com/reader/
- 4 http://www.google.com/reader/view/
- 3 http://bit.ly/7iGMqZ
- 3 http://labs.ceek.jp/hbnews/list.cgi
- 3 http://www.google.co.jp/search?hl=ja&source=hp&q=java+空白+チェック&lr=&aq=5&oq=java+空白
- 3 http://www.google.co.jp/search?sourceid=navclient&hl=ja&ie=UTF-8&rlz=1T4ADBR_jaJP305JP306&q=オザケン復活
