简体   繁体   中英

To change navigation drawer title icon image in Android

I have downloaded a Android Navigation drawer sample project and trying to use that. At the initial state, i don't know how to change the navigation drawer title icon to different icon image. where exactly is this image located specifically? Is it under any specific Res->drawable folder? Please find the screenshot, where I rounded the navigation title icon image, which I want to change now.

在此处输入图片说明

You can change it in your AndroidManifest.xml, put your icon in your res/drawable folder and set the "logo" param to your icon like this:

<manifest>
    ...
    <application
        ...
        android:logo="@drawable/your_image_file_name">
    </application>
    ...
</manifest>

You can find it being set in your manifest. It automatically accesses @drawable/ic_launcher as your app icon

 <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.Byustudiestab" >

您应该在AndroidManifest.xml中更改应用程序图标

android:icon="@drawable/ic_launcher"

where exactly is this image located specifically? Is it under any specific Res->drawable folder?

To find where the image is located in eclipse, do the following: res -> drawable

Also the image might be locate in either drawable-hdpi, drawable-ldpi, drawable-xhdpi, drawable-xxhdpi

Once you find the image location, replace the image with an image of your choice. Either give the image a new name or keep it the same name as the old image. If you decide to give the image a new name you will have to head on over to the AndroidManifest.xml and replace the old name given to the old image with the new name that you gave the new image.

android:logo="@drawable/your_image_file_name"

Another option:

getSupportActionBar().setLogo(R.drawable.yourImage);

or

getActionBar().setLogo(R.drawable.yourImage);

Note: Attribute "logo" is only used in API level 11 and higher android:logo requires api (if you don't use getSupportActionBar)

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