In pre API 21 when setting the app:itemBackground attribute in the Navigation View removes the content padding. Is there a way to revert this without using the new actionLayout attribute to create a custom view for the items?
Here is the screenshot of what happens:
This is the background:
<?xml version="1.0" encoding="utf-8"?> <item> <shape android:shape="rectangle"> <solid android:color="@color/darkGray"/> </shape> </item> <item android:left="-1dp" android:right="-1dp" android:top="-1dp"> <shape> <solid android:color="@android:color/transparent"/> <stroke android:width="1dp" android:color="@color/status_gray"/> </shape> </item> <?xml version="1.0" encoding="utf-8"?> <item> <shape android:shape="rectangle"> <solid android:color="@color/black"/> </shape> </item> <item android:bottom="-4dp" android:right="-4dp" android:top="-4dp"> <shape android:shape="rectangle"> <solid android:color="@android:color/transparent"/> <stroke android:width="4dp" android:color="@color/green"/> </shape> </item> <item android:left="-1dp" android:right="-1dp" android:top="-1dp"> <shape> <solid android:color="@android:color/transparent"/> <stroke android:width="1dp" android:color="@color/status_gray"/> </shape> </item> <?xml version="1.0" encoding="utf-8"?> <item android:drawable="@drawable/dr_nav_view_item_bg_selected" android:state_checked="true"/> <item android:drawable="@drawable/dr_nav_view_item_bg_normal" android:state_checked="false"/> And finally the navigation view:
<android.support.design.widget.NavigationView android:id="@+id/navigation_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:background="@color/darkGray" android:fitsSystemWindows="true" app:headerLayout="@layout/header_navigation_view" app:itemBackground="@drawable/dr_nav_view_item_bg" app:itemIconTint="@color/nav_view_icon_color" app:itemTextColor="@color/nav_view_text_color" app:menu="@menu/menu_navigation_view" app:theme="@style/NavigationViewStyle"/> Please note that in post API 21 the padding is still there.
No comments:
Post a Comment