Question

Previously I made some apps with Adobe Flash Builder. That's works great but is not the best choice is some cases so I start with developing Android apps with use of ADT.

Like in Flash Builder you can set several icons for different screen resolutions. I can understand why but found it is not really necessary when creating one high resolution icon, this works fine (scaling down is better than scaling up). This also avoid the extra work that is needed to create these icons, just one icon.

Long story short, I want to create just one icon, 144x144 pixels at 96dpi and tell Android to use this icon.

Also I want to point the application icon to the asset directory instead of the res/drawable directory. The reason for this is that the icon can be reused by the (web-)application and for another reason, I have made a webApp tool to create a compressed version of a webApp and put the contents in the asset directory of a Android project.

Because the webApp can also run in the browser I have already created some icons (like favicon, apple-touch-icon and apple-touch-startup-image) and want to reuse these icons in the Android project automaticly.

The idea is also to create an application project template so it is quite easy to create a android app of a webApp.

Question

Andy idea how to change the location of for example the application icon? Using a path doesn't work (it generates an error, can't compile).

android:icon="@drawable/ic_launcher"

android:icon="assets/appicon.png"  #<- doesn't work
Was it helpful?

Solution

Actually found the solution myself and is pretty simple. The only thing that is a bit tricky in ADT to validate the new declaration because at first 'it says' that the declaration is invalid. The workaround is to cut (ctrl+X) the declaration, do a project clean by Project|Clean and then put it back by paste it again (ctrl+V). Weird but true ;-)

You can declare a string resource like this (in XML file):

<resources>
    <string name="app_icon">assets/appicon.png</string>
</resources>

android:icon="@string/app_icon" <- this works

Then you can use just one high-res icon image as icon for all devices! Looks great! See also picture below (between red rectangle ;-)):

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top