Reputation: 11
I'm trying to make a Navigation Drawer, and inside the NavigationView
I've added the layout_gravity="start"
attribute, but it wont hide the View. this is my code:
<RelativeLayout ... >
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/navigation_menu"></android.support.design.widget.NavigationView>
</RelativeLayout>
What could be wrong? Thanks.
Upvotes: 1
Views: 6113
Reputation: 186
I hope this works for you because layout_gravity cannot be used inside Relativelayout.
<androidx.drawerlayout.widget.DrawerLayout>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/navigation_menu"></android.support.design.widget.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
Upvotes: 0
Reputation: 5684
If you intend for the NavigationView to behave as a drawer, then the root View should be <android.support.v4.widget.DrawerLayout>
, instead of <RelativeLayout>
Upvotes: 2