I cannot use library of designs how to change color onclick in this code?
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="new order"
/>
I cannot use library of designs how to change color onclick in this code?
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="new order"
/>
I would rather change the color at runtime than adding a style for change on selection to keep ripple feel. Here you set color based on selection at code level
setBackgroundColor(Color.RED);
Check this for more
https://developer.android.com/reference/com/google/android/material/tabs/TabItem
Have you tried using an xml color selector?
create an xml file like this in the drawable directory:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/colorAccent" android:state_selected="true"/>
<item android:drawable="@color/colorPrimary"/>
</selector>
and in your tablayout xml code:
android:background="@drawable/drawable_xml_selector"
I hope this helps.