简体   繁体   English

如何创建一个上面有图标的菜单?

[英]How to create a menu with an icon above?

I need your help on how to add or make a menu with icons or options above it:关于如何添加或制作带有图标或选项的菜单,我需要您的帮助:

Like this preview.喜欢这个预览。

Also, I need help on how to add an icon before the text/title of the menu.另外,我需要有关如何在菜单的文本/标题之前添加图标的帮助。

you can use android:icon like this:你可以使用 android:icon 像这样:

<item
            android:id="@+id/xxxx"
            android:icon="@drawable/zzzz"
            android:title="xxxx" />

and put zzz.png in res/drawble folder.并将 zzz.png 放在 res/drawble 文件夹中。
more information about drawable:有关可绘制的更多信息:
https://www.vogella.com/tutorials/AndroidDrawables/article.html https://www.vogella.com/tutorials/AndroidDrawables/article.html
you can also use mipmap instead of drawable.你也可以使用 mipmap 代替 drawable。
I recommand "Head First Android Development: A Brain-Friendly Guide" book to find answer of similar questions.我推荐《Head First Android Development: A Brain-Friendly Guide》一书来寻找类似问题的答案。

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

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