I have an Android app with a navigation drawer in it. The drawer gets its items from a menu resource file.
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
The active item has a semi-transparent layer above it, it's the default stuff. My problem is with the size/margin of that layer.
Instead of this: https://i.sstatic.net/Zlp9p.png
I can make it square following this answer, but it still has a small margin around it.
How can I achieve it?
You can use the itemShapeInset*
attributes to fill the entire space:
<com.google.android.material.navigation.NavigationView
app:itemShapeInsetStart="0dp"
app:itemShapeInsetEnd="0dp"
app:itemShapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Nav.Square"
and the itemShapeAppearanceOverlay
to have square corners:
<style name="ShapeAppearanceOverlay.Nav.Square" parent="">
<item name="cornerSize">0dp</item>
</style>