I am using Design TabLayout,
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabBackground="@color/ColorPrimary"
app:tabIndicatorColor="@color/orange"
app:tabIndicatorHeight="3dp"
/>
I have added customview to Tabs
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null">
<ImageView
android:id="@+id/imgTab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/tab_image"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"/>
<TextView
android:id="@+id/tabTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/imgTab"
android:text="Home"
android:background="@null"
android:layout_centerHorizontal="true"
android:textColor="@color/selector_tab_text"/>
</RelativeLayout>
tab.setCustomView(view);
I want to change image in the custom view when Tab is Selected. Tried using Selector on imageview it does not work. I cannot get view assigned to Tab in runtime, it only contains setCustomView methode. How to achieve it?