自定义 actionLayout 未显示在 NavDrawer 项中

Par*_*ker 2 android android-layout android-xml

我在为导航抽屉中的菜单项使用自定义视图时遇到了一些问题。当我使用android:actionLayout任何东西时,尽管有一个有效的布局。显示项目文本,但未显示自定义布局中的任何内容。从我在文档中读到的内容来看,我不应该为此需要任何 java 代码,并且应该能够纯粹在 xml 中进行设置,对吗?

我的活动抽屉和actionLayout xml文件如下:

activity_main_drawer.xml 文件:

<group android:checkableBehavior="none" >
    <item ... />
    <item ... />
    <item ... />
</group>

<group android:id="@+id/menu_bottom" android:checkableBehavior="none">
    <item ... />
</group>

<group android:id="@+id/bookmark_list" android:checkableBehavior="single">
    <item
        android:id="@+id/nav_bookmark"
        android:actionLayout="@layout/nav_bookmark_header_layout"
        android:title="Some text"
        app:showAsAction="ifRoom" />
</group>
Run Code Online (Sandbox Code Playgroud)

layout/nav_bookmark_header_layout.xml 文件:

<TextView
    android:id="@+id/counterView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Custom text"/>
Run Code Online (Sandbox Code Playgroud)

Par*_*ker 5

啊,找到了。android:actionLayout应该app:actionLayout