Is it possible to set navigation item background color dynamically
Navigation View
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:background="@color/white"
app:itemIconTint="@color/navigation_color"
app:itemTextColor="@color/navigation_color"
app:itemBackground="@drawable/drawer_selector"
app:headerLayout="@layout/nav_header"
app:menu="@menu/activity_home_drawer"
/>
drawable_selector
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/shape_rectangle_checked"
android:state_checked= "true" />
<item android:drawable="@drawable/shape_rectangle" />
</selector>
Thanks in advance