android - 自定义 actionLayout 未显示在 NavDrawer 项目中

标签 android android-layout android-xml

我在为抽屉导航中的菜单项使用自定义 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/

相关文章:

android - 在 Android 上监控文件访问

android - 与屏幕右侧对齐,Android 有边距

android - ListFragment onListItemClick - 如何知道点击了哪个组件

android - 有什么方法可以将 View 稍微放在其父布局之外?

android - 如何在不反转所选项目的情况下从左到右反转微调器?

android - XmlPullParser - 从具有特定父元素的元素中提取

java - Android中JVM的堆大小

android - 索引 1 处的绑定(bind)值为 null,从 react-native 中的 asyncstorage 获取数据

android - Webview 在右侧添加空白

android - 将圆圈添加到 Android UI?