http://terryyamg.blogspot.tw/2014/06/android-splashscreen.html
另一種方法
1.在 res/drawable/新增launch_screen.xml 上方加入android:opacity="opaque" 中間放入logo圖片並置中
2.在 res/values/styles.xml 新增一個AppTheme.Launcher
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <style name="AppTheme.Launcher"> <item name="android:windowBackground">@drawable/launch_screen</item> </style> </resources>
3.在AndroidManifest.xml加入 android:theme="@style/AppTheme.Launcher"
4.最後MainActivity.java
package com.terryyamg.launchscreenstest; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { setTheme(R.style.AppTheme); //加入此行 super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }
檔案下載:
https://github.com/terryyamg/LaunchScreensTest
參考來源:
https://plus.google.com/+AndroidDevelopers/posts/Z1Wwainpjhd
沒有留言 :
張貼留言