System network and logo configuration above android8.0

The application icon used to be basically the same old adaptation, when testing

Huawei Mate 20 Pro (LYA-AL00) android9.0

VIVO Nex dual screen version (V1821A) android9.0

Pixel android9.0  

Xiaomi MIX3

Mi 6X android8.1.0

Test app icon issues are all ok

Tested on Xiaomi 8android9.0, the icon is stretched and enlarged

Solution

1. Open the app/build.gradle file and check to make sure that the targetSdkVersion has been specified to 26 or higher, mine is 28

2. Open the AndroidManifest.xml file

<application
    android:name=".application.QtsApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_logo"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_logo"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:networkSecurityConfig="@xml/network_security_config"
    >

Pay special attention to android:icon, through this attribute, we specify the icon of the application as the ic_logo file in the mipmap directory

3. For adaptation, android studio clicks on File——New——Image Asset, and clicks the Enter key to open the Asset Studio editor

 

Resize You can adjust the size of the picture, and the picture on the right will be adjusted to the appropriate size

Click OK to adapt successfully

2. System network adaptation above android8.0, for some mobile phones cannot enable network adaptation, in res-xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" overridePins="true" />
            <certificates src="user" overridePins="true" />
        </trust-anchors>
    </base-config>
</network-security-config>

Then inside the AndroidManifest

<application
    android:name=".application.QtsApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_logo"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_logo"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:networkSecurityConfig="@xml/network_security_config"
    >

done~

Guess you like

Origin blog.csdn.net/qq_22576071/article/details/88050257