Splash Screen Image for landscape and Portrait using Theme

前端 未结 2 1869
猫巷女王i
猫巷女王i 2021-01-07 13:12

I have two full screens splash images, one is for landscape and another is for portrait mode.I want to implemented theses images as splash as per the orientation of the devi

相关标签:
2条回答
  • 2021-01-07 14:03

    this is not answer of your Question But ..

    Spash screen is to wait till Activity Ready , Not to make user Wait more

    so what about trying Diffrent way to make Splash screen , it`s built in

    instead of white or black screen

    Go to youe Manifest

    change your app style like this

    <activity
                android:name=".MainActivity"
                android:label="@string/app_name"
                android:theme="@style/splashScreenTheme">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
    

    where splashScreenTheme is

    <style name="splashScreenTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
            <item name="android:windowBackground">@drawable/splash_screen</item>
        </style>
    

    Sure you can change parent and make new drawable "Splashscreen" this is mine

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
        <!-- The background color, preferably the same as your normal theme -->
        <item android:drawable="@android:color/holo_blue_light"/>
        <!-- Your product logo - 144dp color version of your app icon -->
        <item>
            <bitmap
                android:src="@drawable/splash_logo"
                android:gravity="center"/>
        </item>
    </layer-list>
    

    Now your app Style changed you can reset it in your main Activity Oncreate

    @Override
        protected void onCreate(Bundle savedInstanceState) {
            setTheme(R.style.AppTheme222);
    }
    
    0 讨论(0)
  • 2021-01-07 14:04

    If you must use theme approach then Please create a separate styles.xml file into new values-land/ folder into res folder...

    0 讨论(0)
提交回复
热议问题