Suppose I have a cardView Layout which have a TextView and ImageView. I showed them in RecyclerView. If I click on the view the textColor and the drawable color will become red. and then if I click another view, that clicked view will be red and prevoius will convert to black. I did the same thing in bottomNavigationView using custom color.
Here is the layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/item_layout_card_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="10dp"
app:cardCornerRadius="4dp"
app:cardElevation="2dp"
app:cardMaxElevation="3dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/item_image_view"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:scaleType="centerCrop"
android:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/item_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/item_image_view"
android:layout_centerHorizontal="true"
android:layout_marginBottom="5dp"
android:gravity="center"
android:text="Item"
android:textColor="#000000"
android:textSize="12sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>