java - 为什么 android 启动画面不显示在 kitkat 和旧设备的横向方向上?

标签 java android splash-screen android-4.4-kitkat landscape

我在我的 android 应用程序(具有 android API 级别 14-26 目标支持)中添加了闪屏,如下所示:

在我的 AndroidManifest.xml 中

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

在 styles.xml 中,SplashTheme 定义为:

<style name="SplashTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">

        <item name="android:windowBackground">@drawable/splash_graphic</item>
        <item name="android:windowNoTitle">true</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowContentOverlay">@null</item>
    </style>

我的splash_graphic.xml如下:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <color android:color="@color/colorPrimary"/>
    </item>
    <item>
        <bitmap android:src="@drawable/my_logo" android:tileMode="disabled" android:gravity="center" />
    </item>
</layer-list>

我的 Splash Activity 为:

public class SplashActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        startActivity(new Intent(SplashActivity.this, ActivationActivity.class));
        finish();
    }
}

我的奇怪问题是: 在 Lollipop 和更新的设备上,启动画面在横向和纵向屏幕方向上都可以正常工作,但它只适用于 Kitkat 和 pre-kitkat 设备上的纵向屏幕方向。我怎样才能让它在 kitkat 和 pre-kitkat 设备上也适用于横向?

最佳答案

经过这么多小时的搜索,我终于找到了解决我的奇怪问题的方法,这不是编码解决方案。然而,这听起来有点尴尬, 我想分享它只是因为它对我有用,而且我认为它对其他人也有帮助。所以,这是我的解决方法:

原因:

This problem was being caused by the default home launcher app ,which manages apps showcasing in Landscape and Portrait screen orientation of devices [I observed the problem on 1. Huawei MediaPad T1 7.0 Tablet 2. Lenovo a-319 Rockstar and 3.Samsung Galaxy S Duos 7562 ]. But I did not observe any problem on any devices[Splash-screen worked on any screen orientations on 1. Samsung Galaxy J Max SM-T285YD Tab 2.Samsung J 7 Prime phone] that had Lollipop or newer android OSes.

解决方案:

So, I changed the default home launcher app on devices which had problem. EMUI launcher of Huawei MediaPad tab and Fly launcher of Lenovo a-319[I had rooted this device, so launcher is different than other Lenovo phones] were replaced with Google Now Launcher from google play, which now is not officially supported by google. As Samsung S Duos 7562 did not support Google Now Launcher, its TouchWiz launcher was replaced with Nova Launcher . After default home launcher app replacement, now, the problem is solved on all target devices.

关于java - 为什么 android 启动画面不显示在 kitkat 和旧设备的横向方向上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46952337/

相关文章:

java - 将图像序列化为android

JavaFX - 启动画面未显示

iPad3 网络应用启动画面无法在横向模式下工作

java - 如何获取 Map 中的字节值

java - 如何控制每个区域服务器读取 HBase 表的映射器数量

java - 我如何从 Java 调用 Perl?

java - Button.setOnClickListener(这个);错误

android - 从图像或 <LinearLayout>/<GridView> 等创建平铺背景

java - Android,客户端服务器通信

android - 如何在 5 秒后自动显示 Activity ?