我用来ActionMenuView
渲染菜单。ActionMenuView
但是重叠最后一个动作图标的溢出按钮:
这是我的代码:
<RelativeLayout
android:id="@+id/main_topBar"
android:layout_width="match_parent"
android:layout_height="90dp"
android:background="@drawable/header_pattern_back"
android:animateLayoutChanges="true"
android:padding="0dp">
<ImageView
android:id="@+id/main_backBtn"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/arrow_back_white"
android:padding="4dp"
android:layout_margin="8dp"/>
<androidx.appcompat.widget.ActionMenuView
android:id="@+id/main_topbar_menu"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_alignParentRight="true"
android:gravity="center_vertical|left"/>
</RelativeLayout>
在java中
ActionMenuView menuView = findViewById(R.id.main_topbar_menu);
MenuBuilder menuBuilder = (MenuBuilder) menuView.getMenu();
getActivity().getMenuInflater().inflate(R.menu.recieved_letter_commands, menuBuilder);
R.menu.recieved_letter_commands.xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/letterCommand_delete"
android:title="delete"
android:icon="@drawable/ic_delete_white_24dp"
app:showAsAction="always"
android:iconTint="#777"/>
<item
android:id="@+id/letterCommand_archive"
app:showAsAction="always"
android:title="archive"
android:icon="@drawable/ic_archive_income"
android:iconTint="#777" />
<item
android:id="@+id/letterCommand_ref"
android:title="Refrences"
app:showAsAction="always"
android:iconTint="#777"
android:icon="@drawable/ic_reply_gray"/>
<item
android:id="@+id/letterCommand_receivers"
android:title="Recievers"
app:showAsAction="never"
android:iconTint="#777"/>
<item
android:id="@+id/letterCommand_moveToFolder"
android:title="Move To Folder..."
app:showAsAction="never"
android:iconTint="#777"/>
<item
android:id="@+id/letterCommand_setUnread"
android:title="Set as unread"
app:showAsAction="never"
android:iconTint="#777"/>
<item
android:id="@+id/letterCommand_close"
android:title="Close"
app:showAsAction="never"
android:iconTint="#777"/>
<item
android:id="@+id/letterCommand_note"
android:title="Note"
app:showAsAction="never"
android:iconTint="#777"/>
</menu>