简体   繁体   中英

Dynamically change application theme depending on android:icon

I have integrated splash screen into my app from android manifest I gave it a newly made SplashTheme and whenever the onActivityCreated called I change it to the one that is needed. Now , in splash.xml file which you can see below:

<item>
    <color android:color="@color/colorPrimary" />
</item>

<item>
    <bitmap
        android:gravity="center"
        android:src="@mipmap/ic_launcher" />
</item>

I put my launcher ic_launcher in the center but when the device in which the app is installed uses round icons the splash screen still shows the "original" icon. I know because I put here ic_launcher instead of ic_launcher_round but I would like to make this part dynamic, to recognize if the devices uses round icons put ic_launcher_round and the opposite.

Here is the part of my AndroidManifest.xml :

Afaik, you cannot achieve the behavior you expect, simply because there does not exist an API, that would provide you whether current launcher uses round icon or a default icon.

Instead, you should construct your splash screen in a way, that is not dependent on the default launcher implementation of the device. Normally, you should have the same image regardless launcher uses round or normal icons.

Leave launcher icons aside and create a resource specifically for splash screen.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM