Reputation: 4811
I'm having a slight issue here where the overflow options for the ActionBar
are showing up in the emulator but not the layout preview. I'm currently using Android Studio v 2.1.3.
Has anyone else come across the same issue?
Layout Preview
Emulator Screenshot
Upvotes: 3
Views: 295
Reputation:
In your layout file, add the tools:menu
attribute directly to the Toolbar
widget:
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
tools:menu="@menu/your_menu"/>
According to the 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).
However, I find that it only works if:
Toolbar
widget@menu/
prefixUpvotes: 1
Reputation: 6712
Try to add a tools:menu
to your root view in the layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:menu="menu1,menu2" />
more info here: http://tools.android.com/tech-docs/tools-attributes
Upvotes: 0