Android xml中定义的SplashScreen方法(无活动)不会出现
我定义了闪屏,就像其他很多没有外部活动的闪屏一样,但它不适合我,我不明白为什么 图像是否有任何限制?还尝试了许多其他图像 这是我的splash.xmlAndroid xml中定义的SplashScreen方法(无活动)不会出现,android,splash-screen,Android,Splash Screen,我定义了闪屏,就像其他很多没有外部活动的闪屏一样,但它不适合我,我不明白为什么 图像是否有任何限制?还尝试了许多其他图像 这是我的splash.xml <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque"> <item>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<item>
<bitmap
android:gravity="center"
android:src="@drawable/splash_logo" />
</item>
</layer-list>
加载“活动”时,会显示空白的白色屏幕,而不是图像,可能会显示一秒钟。我搜索了这个方法,似乎它与其他人所做的是一样的。不明白怎么了
编辑:
我已经在另一个设备OS 5.0上测试了它,它可以工作,但在6.0上无法编辑
将其从活动中删除
setTheme(R.style.AppTheme)
试试这个
Style.xml
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/splash_background</item>
</style>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/colorPrimary" />
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher" />
</item>
</layer-list>
清单
<activity android:name=".SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
这应该是一个注释。但我不能发表评论。我也面临同样的问题。请检查图像的大小。请尝试压缩图像,然后再试一次,它可能会对您有所帮助。请务必让我知道。您的图像根本没有显示,或者仅在大约1秒后才显示?它根本没有显示。请添加您的活动。好的,已更新,这只是示例oncreate@JemoMgebrishvili从应用程序中删除setTheme(R.style.AppTheme)
activity@JemoMgebrishvili检查他是否正在设置另一个主题setTheme(R.style.AppTheme)@JemoMgebrishvili很高兴帮助你
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/splash_background</item>
</style>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/colorPrimary" />
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher" />
</item>
</layer-list>
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
startActivity(new Intent(SplashActivity.this, MainActivity.class));
// close splash activity
finish();
}
}
<activity android:name=".SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>