我想在我的应用程序中制作一个启动画面,因为我需要知道如何以全屏显示图像.这可以通过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);
}
}
Run Code Online (Sandbox Code Playgroud)
这个splash_screen.xml怎么样?谢谢您的帮助.
小智 28
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/image" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
并在代码中添加
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Run Code Online (Sandbox Code Playgroud)
在setContentView之前(R.layout.splash_screen);
Rav*_*avi 28
显示全屏幕启动活动的最佳方法是将此行放在活动代码下的清单中
机器人:主题= "@安卓风格/ Theme.Light.NoTitleBar.Fullscreen"
您也可以使用其他主题
Theme.Black.NoTitleBar.Fullscreen
Theme.NoTitleBar.Fullscreen
<activity
android:name="com.example.SplashActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
最新的Api Lollipop及以上
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
Run Code Online (Sandbox Code Playgroud)
为splash活动定义此主题并在清单中提供它
机器人:主题= "@风格/ Theme.AppCompat.Light.NoActionBar.FullScreen"
| 归档时间: |
|
| 查看次数: |
42050 次 |
| 最近记录: |