我在菜单项上设置动作布局,设置背景色和图像,但这不受尊重。在我的活动中,我有:
getMenuInflater().充气(R.menu.submit\u操作,菜单);
我的提交行动是:
<;菜单xmlns:android=”http://schemas.android.com/apk/res/android"
xmlns:app=”http://schemas.android.com/apk/res-auto“>;
<;项目名称:id=“@+id/action\u submit”
android:actionLayout=“@layout/check”
app:showAsAction=“始终”/>;
</菜单>;
我的支票版式是
<;RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android"
style=“?android:attr/actionButtonStyle”
android:layout\u width=“fill\u parent”
android:layout\u height=“fill\u parent”
android:background=“#e8e8e8”
android:clickable=“true”
android:contentDescription=“lol”>;
<;图片框
android:layout\u width=“包装内容”
android:layout\u height=“包装内容”
android:contentDescription=“@null”
android:scaleType=“centerInside”
android:src=”https://stackoverflow.com/questions/23211761/@可绘图/ic_action_tick”/>;
</相对寿命>;
但即使有了所有这些设置,操作栏也是这样显示的,根本不显示我的菜单项(但它在那里,因为它响应单击,但不显示):
尝试app:actionLayout=“@layout/check”而不是android:actionLayout=“@layout/check”
如果您使用的是ActionbarSherlock或AppCompat,则android:命名空间将不适用于MenuItems。这是因为这些库使用了模仿Android API的自定义属性,因为它们在早期版本的框架中并不存在