我在为抽屉导航中的菜单项使用自定义 View 时遇到了一些问题。当我使用 android:actionLayout
时,尽管布局有效,但没有任何变化。显示项目文本,但未显示自定义布局中的任何内容。根据我在文档中阅读的内容,我不需要为此使用任何 Java 代码,并且应该能够纯粹在 xml 中设置它,对吧?
我的activity drawer和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>
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"/>
最佳答案
啊,找到了。 android:actionLayout
应该是 app:actionLayout
关于android - 自定义 actionLayout 未显示在 NavDrawer 项目中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45172622/