1

I'm building an app in android studio with a menu (lateral drawer), and i want to see the preview in the menu.xml file, but it shows a grey screen, it shows fine in the emulator but not in android studio

It works fine without tools:showIn="navigation_view" but i want to see the preview with navigation_view like the image below

This is what the preview looks like

It should look like this

I have tried rebuilding the app, which is the most common solution, but it still doesn't show up

This is the xml file of the menu

<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:showIn="navigation_view"> <group android:checkableBehavior="single"> <item android:id="@+id/nav_inicio" android:icon="@drawable/ic_message" android:title="Inicio" /> <item android:id="@+id/nav_animales" android:icon="@drawable/ic_chat" android:title="Animales" /> <item android:id="@+id/nav_agregar" android:icon="@drawable/ic_profile" android:title="Agregar" /> <item android:id="@+id/nav_editar" android:icon="@drawable/ic_profile" android:title="Editar" /> <item android:id="@+id/nav_borrar" android:icon="@drawable/ic_profile" android:title="Borrar" /> </group> <item android:title="Communicate"> <menu> <item android:id="@+id/nav_share" android:icon="@drawable/ic_share" android:title="Share" /> <item android:id="@+id/nav_send" android:icon="@drawable/ic_send" android:title="Share" /> </menu> </item> </menu> 

dependencies

apply plugin: 'com.android.application' android { compileSdkVersion 29 buildToolsVersion "29.0.0" defaultConfig { applicationId "expo.desarrollo.simbad_app" minSdkVersion 19 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'com.google.android.material:material:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' } 

2 Answers 2

0

Try doing invalidate Caches/ Restart by going to File in the Android Studio. If still no showing then, try force refresh layout from the XML design screen, can't find it? follow this link:

Sign up to request clarification or add additional context in comments.

Comments

0

Please Add Design Library in Gradle Build (App Module) after that hope it will work.

implementation 'com.android.support:design:28.0.0'

1 Comment

The app uses androidx and that library is the same as implementation 'com.google.android.material:material:1.0.0' in androidx, adding com.android.support:design:28.0.0 gives an error

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.