gpt4 book ai didi

android - [闪屏]如何全屏显示图像?

转载 作者:IT老高 更新时间:2023-10-28 23:37:38 25 4
gpt4 key购买 nike

我想在我的应用程序中制作一个启动画面,因为我需要知道如何全屏显示图像。这可以由 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 ?感谢您的帮助。

最佳答案

显示全屏启动 Activity 的最佳方式是将此行放在 list 中的 Activity 标记下

android:theme="@android:style/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>

最新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>

为启动 Activity 定义这个主题并在 list 中提供它

android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"

关于android - [闪屏]如何全屏显示图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6918430/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com