Splash Android interface stretch under a cold start problem solving

Symptom

To prevent black or white screen problem when the app starts. You need to select cold start process. Implementation as follows:

Add custom theme styles file:

<style name="ThemeSplash" parent="Theme.AppCompat.Light.NoActionBar">
     <item name="android:background">@drawable/bg_welcome_default</item>
     <item name="android:windowNoTitle">true</item>
     <item name="android:windowFullscreen">true</item>
     <item name="windowActionBar">false</item>
     <item name="windowNoTitle">true</item>
</style>

Manifest file using the theme:

 <application
        android:allowBackup="true"
        android:label="@string/app_name"
        android:supportsRtl="true">
        <activity
            android:theme="@style/ThemeSplash"
            android:name=".SplashActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

 

The size of the app bg_welcome_default pictures of three 640 * 960,750 * 1334,1242 * 2208.

Properly in an aspect ratio that matches the phone will be in a similar millet 9 (1080 * 2340) where stretching occurs. (Note: this can not be used to replace the aspect ratio of the picture 1242 * 2208 1080 * 2340 1242 * 2208 because the aspect ratio of the phone at the same pixel density there will stretch, so that the replacement can not solve the fundamental problem.)

problem causes

It does not match the screen when using the picture as a full screen picture aspect ratio and the picture aspect ratio.

Solution

FIG alone cut icons, background custom drawing, as follows:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape >
            <solid android:color="@color/white"/>
        </shape>
    </item>
    <item android:left="10dip" android:top="10dip">
        <bitmap android:src="@drawable/bg_welcome"
            android:gravity="center"/>
    </item>
</layer-list>

Extended problem

After processing the above method, Splash interfacial tension problem has been solved, but there is a slight problem, millet statusBar 9 is not filled with pictures. Investigation through the channel length, custom code can use the following code relating to:

    <style name="ThemeSplash" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@drawable/bg_welcome_default</item>
        <item name="android:statusBarColor">@android:color/transparent</item>

        <!--<item name="android:windowNoTitle">true</item>-->
        <!--<item name="android:windowFullscreen">true</item>-->
        <!--<item name="windowActionBar">false</item>-->
        <!--<item name="windowNoTitle">true</item>-->

    </style>

Note: This topic is on v21 \ styles.xml, the above code and do not conflict.

Here, a cold boot Splash screen stretched state basic problem will be solved.

 

Guess you like

Origin www.cnblogs.com/renhui/p/12275051.html