我想在我的应用程序中制作一个启动画面,因为我需要知道如何以全屏显示图像.这可以通过XML或Java代码制作吗?如何?现在我刚刚做了这个:
public class SplashScreen extends Activity { private static final int STOPSPLASH = 0; private static final long SPLASHTIME = 5000; private Handler splashHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case STOPSPLASH: //remove SplashScreen from view Intent intent = new Intent(SplashScreen.this, jetpack.class); startActivity(intent); break; } super.handleMessage(msg); } }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash_screen); Message msg = new Message(); msg.what = STOPSPLASH; splashHandler.sendMessageDelayed(msg, SPLASHTIME); } }
这个splash_screen.xml怎么样?谢谢您的帮助.
并在代码中添加
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
在setContentView之前(R.layout.splash_screen);
显示全屏幕启动活动的最佳方法是将此行放在活动代码下的清单中
机器人:主题= "@安卓风格/ Theme.Light.NoTitleBar.Fullscreen"
您也可以使用其他主题
Theme.Black.NoTitleBar.Fullscreen
Theme.NoTitleBar.Fullscreen
最新的Api Lollipop及以上
为splash活动定义此主题并在清单中提供它
机器人:主题= "@风格/ Theme.AppCompat.Light.NoActionBar.FullScreen"