默认情况下,Android App在点击App logo到App完全启动这之间会有一段时间空白期。那么如何做到在用户点击logo图标之后立即打开App的界面而不是一段白屏或黑屏呢? 设置xml在drawable下建立welcome.xml <?xml version="1.0" encoding="utf-8"?> <layer-listxmlns:android="http://schemas.android.com/apk/res/android"> <!--背景色--> <itemandroid:drawable="@color/white"/> <item> <!--图片--> <bitmap android:gravity="center" android:src="@mipmap/welcome_page"/> </item> </layer-list> 设置style<!-- Base application theme. --> <stylename="AppTheme"parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> </style> <stylename="WelcomeThem"parent="AppTheme"> <itemname="android:windowBackground">@drawable/welcome</item> </style> 清单文件中配置style<!-- 欢迎页 --> <activity android:name=".ui.WelcomeActivity" android:windowSoftInputMode="adjustNothing"android:theme="@style/WelcomeThem"> <intent-filter> <actionandroid:name="android.intent.action.MAIN"/> <categoryandroid:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> Activity中不需要设置setContentView()
publicclassWelcomeActivityextendsAppCompatActivity{
@Override
protectedvoidonCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
Intent intent = newIntent(this, MainActivity.class);
startActivity(intent);
finish();
}
}
不需要为你的SplashActivity设置一个视图,这个视图来自于主题,在主题中为你的SplashActivity设置UI就足够了。 (责任编辑:最模板) |

淘宝客|返利网|易购51模板
人气:13549
Magento时尚服饰Bonnie外贸模
人气:199
SuperShop外贸综合通用mage
人气:181
ecshop高仿趣玩模板|ecshop礼
人气:988
zencart羽绒服服装模板
人气:2116
ecshop仿活力达保健品网|保
人气:749