How to change launcher icon and it's label from the application

后端 未结 2 1856
醉酒成梦
醉酒成梦 2020-12-10 00:06

How can I change the launcher icon and its label from my application runtime in Android? (if it is possible)
I mean the properties defined in AndroidManifest.xml<

2条回答
  •  不知归路
    2020-12-10 00:39

    Edit: your original answer didn't specify you wanted to do it at runtime. Below the line is how to do it before it compiles. As for doing it programmatically at runtime:

    From this answer:

    You cannot change the manifest or the resource in the signed-and-sealed APK, except through a software upgrade.

    But also, the accepted answer figured out a "hack" or some cheating way to do it (I presume). I haven't tested it, but there is a source for you to check out.

    Or, this link apparently describes how to do this using the "widget" approach.


    So lets say your manifest was like this:

    
    
    
        
    
        
    
         ...
    

    You would change the launcher icon by putting images into your drawable folders:

    Project folder --> res --> all the drawables
    

    Then you would change the android:icon="@drawable/ic_launcher" to be android:icon="@drawable/whateverTheNameOfTheImageIsYouPutInTheDrawablesFolders"


    To change the label:

    Open up your strings.xml file which is located:

    Project folder --> res --> values --> strings.xml
    

    And look for the string that looks like this:

    Your App Name
    

    And just change Your App Name to be whatever you want the label to be.


    Summary:

    android:icon="@drawable/ic_launcher" determines your launcher icon, so just add images to the drawable folders and change ic_launcher to whatever the name of image is that you want to be the icon.

    android:label="@string/app_name" determines your "label" so just look for app_name (because the label is referenced to @string/app_name) in your strings.xml file and change the contents of app_name.

提交回复
热议问题