简体   繁体   English

我可以在Android工具栏的溢出菜单中显示图标吗?

[英]Can I show icon in overflow menu of Android Toolbar?

Please take in consideration that I'm refering to the Toolbar Widget(Android L/API 21+) By overflow menu and icons I mean something like this one : 请注意我正在引用工具栏小部件(Android L / API 21+)通过溢出菜单和图标我的意思是这样的:

在此输入图像描述

Something more difficult : Is there any way that the icons appear on the RIGHT side of the text? 更难的是:有没有任何方式图标出现在文本的右侧?

create a menu in menu, for example: main_activity_actions.xml and use this code for the toolbar, try it: 在菜单中创建菜单,例如:main_activity_actions.xml并将此代码用于工具栏,尝试:

    <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:All4One="http://schemas.android.com/apk/res-auto">
    <item android:id="@+id/algo"//some id
        android:icon="@drawable/kami_nomi_zu_shiru_sekai3" //add the image
        android:title="nose"
        All4One:showAsAction="always">
        <menu>
            <item android:id="@+id/WIFI"//option to display on the menu
                android:icon="@drawable/nisekoi1"//this is a option of the submenu
                android:title="@string/WIFI"/>

            <item android:id="@+id/DATOS"
                android:icon="@drawable/nisekoi6" //this one also is a option
                android:title="@string/DATOS"/>

            <item android:id="@+id/BT"
                android:icon="@drawable/sao1"
                android:title="@string/BT"/>

            <item android:id="@+id/NADA"
                android:icon="@drawable/nisekoi6" //the same
                android:title="@string/NADA"/>
        </menu>
    </item>
</menu>

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

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