I need to change selected item color in such condition that mentioned below. Is it possible to do it by drawable selector
xml file?
I can change layout inclusion with listview
if it works.
I need to change any of one:
1) Tint of ImageView
along with TextView
text color
2) LinearLayout
background that holding both TextView
and ImageView
Navigationview
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start">
<include layout="@layout/custommenu"/>
</android.support.design.widget.NavigationView>
custommenu.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:background="#000000"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/selector"
android:gravity="center_horizontal">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:tint="@color/white"
app:srcCompat="@drawable/ic_home_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/red" android:state_pressed="true" />
<item android:drawable="@color/blue" android:state_focused="true" />
<item android:drawable="@color/white" />
</selector>
Don't mark it duplicate if you cannot show me the exact match of my condition. If you cannot answer just ignore it please.
Thanks in advance.