我正在菜单项上设置 actionLayout 并设置背景颜色和图像,但它不受尊重。在我的活动中,我有:
getMenuInflater().inflate(R.menu.submit_action, menu);
我的提交操作是:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_submit"
android:actionLayout="@layout/check"
app:showAsAction="always" />
</menu>
我的支票布局是
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/actionButtonStyle"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#e8e8e8"
android:clickable="true"
android:contentDescription="lol" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:scaleType="centerInside"
android:src="@drawable/ic_action_tick" />
</RelativeLayout>
但即使完成所有这些设置,这就是操作栏的显示方式,根本不显示我的菜单项(但它在那里,因为它响应单击,但不出现):
Try app:actionLayout="@layout/check"
代替android:actionLayout="@layout/check"
.
如果您正在使用ActionbarSherlock
or AppCompat
, the android:
命名空间不适用于MenuItem
s。这是因为这些库使用模仿 Android API 的自定义属性,因为它们在框架的早期版本中不存在。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)