简体   繁体   English

在Android中更改导航抽屉标题图标图像

[英]To change navigation drawer title icon image in Android

I have downloaded a Android Navigation drawer sample project and trying to use that. 我已经下载了一个Android导航抽屉示例项目,并尝试使用它。 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? 它在任何特定的Res-> drawable文件夹下吗? 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: 您可以在AndroidManifest.xml中进行更改,将图标放在res / drawable文件夹中,然后将“ logo”参数设置为图标,如下所示:

<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 它会自动访问@ drawable / ic_launcher作为您的应用程序图标

 <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? 它在任何特定的Res-> drawable文件夹下吗?

To find where the image is located in eclipse, do the following: res -> drawable 要查找图像在Eclipse中的位置,请执行以下操作:res-> drawable

Also the image might be locate in either drawable-hdpi, drawable-ldpi, drawable-xhdpi, drawable-xxhdpi 此外,图像可能位于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. 如果您决定为图像赋予新名称,则必须转到AndroidManifest.xml,并使用为新图像赋予的新名称替换为旧图像赋予的旧名称。

android:logo="@drawable/your_image_file_name" 机器人:标志= “@绘制/ 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) 注意:属性“徽标”仅在API级别11和更高版本中使用android:logo需要api(如果您不使用getSupportActionBar)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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