gpt4 book ai didi

android - menuitem 上的 actionlayout 什么都不做

转载 作者:IT王子 更新时间:2023-10-28 23:39:30 24 4
gpt4 key购买 nike

我在菜单项上设置 actionLayout 并设置背景颜色和图像,但它没有得到尊重。在我的 Activity 中,我有:

getMenuInflater().inflate(R.menu.submit_action, menu);

我的 submit_action 是:

<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>

但即使进行了所有这些设置,操作栏也是这样显示的,根本没有显示我的菜单项(但它在那里,因为它响应点击,但没有出现):

enter image description here

最佳答案

尝试 app:actionLayout="@layout/check" 而不是 android:actionLayout="@layout/check"

如果您使用 ActionbarSherlockAppCompatandroid: 命名空间将不适用于 MenuItem .这是因为这些库使用模仿 Android API 的自定义属性,因为它们在框架的早期版本中不存在。

关于android - menuitem 上的 actionlayout 什么都不做,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23211761/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com