gpt4 book ai didi

java - 启动画面不会显示,只有空白区域

转载 作者:行者123 更新时间:2023-12-02 03:54:34 24 4
gpt4 key购买 nike

因此创建了启动屏幕 png,将其放入可绘制文件夹中(仅创建了一种尺寸以查看其在设备上的外观),但是当应用程序启动时它只是不显示它,只显示白色屏幕。

这是splash.java

public class Splash extends AppCompatActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);

int secondsDelayed = 1;
new Handler().postDelayed(new Runnable() {
public void run() {
Intent intent = new Intent(Splash.this, AppLayoutMain.class);
startActivity(intent);

}
}, secondsDelayed * 1000);
}
}

这是 XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView46"
android:background="@drawable/splashscreen"/>
</LinearLayout>

和 list

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".Splash"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AppLayoutMain"/>

我做错了什么?

最佳答案

将处理程序移至 onResume

@Override
protected void onResume() {
super.onResume();
new Handler().postDelayed(new Runnable() {
public void run() {
Intent intent = new Intent(Splash.this, AppLayoutMain.class);
startActivity(intent);

}
}, secondsDelayed * 1000);
}

xml 也发生变化

android:background="@drawable/splashscreen"

android:src="@drawable/splashscreen"

关于java - 启动画面不会显示,只有空白区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35609126/

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