我在这里遇到了一个小问题,ActionBar
的溢出选项显示在模拟器中,但没有显示在布局预览中。我目前正在使用 Android Studio v 2.1.3。
有没有人遇到同样的问题?
布局预览
模拟器截图
最佳答案
在布局文件中,添加 tools:menu
直接归因于 Toolbar
小部件:
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
tools:menu="@menu/your_menu"/>
根据docs :
tools:menu
Intended for: Any root
<View>
This attribute specifies which menu the layout preview should show in the app bar. The value can be one or more menu IDs, separated by commas (without @menu/ or any such ID prefix and without the .xml extension).
但是,我发现它仅在以下情况下有效:
- 属性直接添加到
Toolbar
小部件 - 该值包括
@menu/
前缀
关于android - 布局预览不显示 ActionBar 溢出选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39366258/