Resource res files and how to change app name and icon

1. res Directory Structure

The res/ directory is organized into subdirectories by resource type:

DirectoryPurpose
drawableGeneral images (e.g., backgrounds, illustrations)
mipmap-prefixedApp icons (Launcher Icons)
valuesStrings, styles, colors, etc.
layoutLayout files

2. Why Are There So Many mipmap and drawable Folders?

To support various screen densities, Android provides multiple directories:

drawable-hdpi      → High density
drawable-xhdpi     → Extra-high density
drawable-xxhdpi    → Extra-extra-high density
drawable-xxxhdpi   → Highest density

The same applies to mipmap, with folders like mipmap-hdpi, mipmap-xhdpi, mipmap-xxhdpi, etc.

How it works: Prepare different resolutions of the same image and place them in the corresponding folders. At runtime, the system automatically selects and loads the most suitable set based on the device’s screen density.


3. How to Reference Resources

3.1 String Resources

Defined in res/values/strings.xml:

<resources>
    <string name="app_name">My Application</string>
</resources>Code language: HTML, XML (xml)

References are used differently depending on the context:

ContextReference FormatExample
In XML files@string/app_nameandroid:text="@string/app_name"
In Java codeR.string.app_namegetString(R.string.app_name)
3.2 Referencing Images and Icons

Note: You cannot use Java syntax like R.mipmap.xxx directly in XML!

Resource TypeIn XMLIn Java Code
Icon (mipmap)@mipmap/ic_launcherR.mipmap.ic_launcher
Image (drawable)@drawable/bg_imageR.drawable.bg_image
Layout—R.layout.activity_main
String@string/app_nameR.string.app_name

Side-by-side example:

<!-- In XML: use @ prefix -->
android:icon="@mipmap/school"Code language: HTML, XML (xml)
// In Java: use R. prefix
setContentView(R.layout.activity_main);Code language: JavaScript (javascript)

4. Resource References in AndroidManifest.xml

Open AndroidManifest.xml. Inside the application tag, you’ll already see several resource references:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">Code language: HTML, XML (xml)
AttributeReferenced ResourcePurpose
android:icon@mipmap/ic_launcherApp icon
android:label@string/app_nameApp name
android:roundIcon@mipmap/ic_launcher_roundRound app icon
android:theme@style/AppThemeApp theme

5. Hands-on Exercise: Change App Name and Icon

Step 1: Change the App Name

Open res/values/strings.xml:

<resources>
    <string name="app_name">FoxDevelop</string>
</resources>Code language: HTML, XML (xml)

After saving, the app name on your device’s home screen will become “FoxDevelop”.

Step 2: Prepare the Icon File
  • Download a PNG icon
  • File naming rules: Do not use hyphens -; only use underscores _, lowercase letters, or numbers
    • ✅ school_bell.png
    • ❌ school-bell.png
Step 3: Place in the Correct Directory

Copy the icon file into res/mipmap-xxhdpi/ (or the corresponding mipmap folder for your target resolution).

Step 4: Modify AndroidManifest.xml
<application
    android:icon="@mipmap/school_bell"
    android:roundIcon="@mipmap/school_bell"
    ... >Code language: HTML, XML (xml)
Step 5: Run Again

Click the ▶ Run button to deploy to the emulator. You should see:

  • The app name on the home screen changes to “FoxDevelop”
  • The app icon becomes the school_bell.png you set

6. Summary

Key PointDescription
Resource reference ruleXML uses @type/name, Java uses R.type.name
Multi-resolution adaptationPlace images for different resolutions in separate folders; the system picks automatically
Change app nameModify app_name in res/values/strings.xml
Change app iconReplace the PNG in the mipmap folder and update android:icon in AndroidManifest.xml
File naming conventionOnly lowercase letters, numbers, and underscores; no hyphens

Remember this in one sentence: XML uses @, Java uses R.; icons go in mipmap, images in drawable, strings in values.

Resource res files and how to change app name and icon

Leave a Reply

Your email address will not be published. Required fields are marked *