Android actionLayout未与工具栏一起显示 [英] Android actionLayout not showing with Toolbar
本文介绍了Android actionLayout未与工具栏一起显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将自定义布局显示为选项菜单中的一项. 这是我到目前为止所做的
I'm trying to show custom layout as an item in options menu. And this is what I have done so far
<item
android:id="@+id/action_profile"
android:orderInCategory="100"
android:title="Profile"
android:actionLayout="@layout/layout_menu_profile"
app:showAsAction="never" />
我尝试了
app:actionLayout="@layout/layout_menu_profile"
以及此 SO链接,但仍仅显示标题-个人资料
as well as per this SO link but still it shows only title - Profile
我通过具有空白活动的Android Studio 1.5创建了新项目. minSDK = 15,targetSDK = 23
I have created new project through Android Studio 1.5 with Blank Activity. with minSDK = 15 and targetSDK = 23
以下是空白活动"中的代码.
Following is the code in Blank Activity.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_home, menu);
MenuItem item = menu.findItem(R.id.action_profile);
return true;
}
我要去哪里错了?
推荐答案
使用app:actionLayout
代替android:actionLayout
.
<item
...
app:actionLayout="@layout/layout_menu_profile"
app:showAsAction="always" />
这篇关于Android actionLayout未与工具栏一起显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文