简体   繁体   English

Android向ActionBar添加按钮

[英]Android add buttons to ActionBar

I have a problem, in my app I need to add 2 buttons to the ActionBar, i change the menù file in this way 我有一个问题,在我的应用中,我需要向ActionBar添加2个按钮,我以这种方式更改菜单文件

<menu
xmlns:android="http://schemas.android.com/apk/res/android">

<item
    android:id="@+id/navigation_drawer"
    android:icon="@drawable/ic_drawer"
    android:title="Drawer"
    android:showAsAction="ifRoom" />

<item android:id="@+id/info"
    android:icon="@drawable/ic_info_outline_white_24dp"
    android:title="info"
    android:showAsAction="ifRoom" />
</menu>

but my items are in the overflow button without the image , only the text , how can I do to take off from there and make images appear on ActionBar ? 但是我的项目在没有图像,只有文本的溢出按钮中,如何从那里起飞并使图像显示在ActionBar上? it would be possible to put one on the left and one to the right of the name of the app ? 是否可以在应用程序名称的左侧和右侧放置一个?

您可以使用android:showAsAction="always"使它们始终显示在ActionBar上。

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

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