Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TabLayout highlite and Ripple effect

I have two question with TabLayout

1)Can i remove TabLayout highlight or change highlight color of tab layout?

2)Can i add ripple effect for tab. Each tab contain TextView i try to add custom background something like this

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?android:colorControlHighlight">
    <item android:drawable="@drawable/btn_white_bg" />
</ripple>

but it doesn't work.

like image 617
Tiberal Avatar asked Jul 24 '15 08:07

Tiberal


People also ask

What is tabLayout?

com.google.android.material.tabs.TabLayout. TabLayout provides a horizontal layout to display tabs.

How do I change the icon size on my Android tablet?

Change icon size on Android devices by going to Settings > Wallpaper & style > App grid and changing it to a grid with fewer or more columns and rows.


2 Answers

To remove the highlight, add the below line to your XML:

app:tabRippleColor="@android:color/transparent"
like image 74
Ranjan Avatar answered Oct 21 '22 02:10

Ranjan


Another solution that works for me

<android.support.design.widget.TabLayout
    android:id="@+id/tab_layout"
    android:minHeight="?attr/actionBarSize"
    android:layout_width="match_parent"
    app:tabMode="fixed"
    app:tabGravity="fill"
    android:clipToPadding="false"
    android:elevation="0dp"
    style="@style/MyCustomTabLayout"
    android:background="@color/colorPrimary"
    app:tabBackground="?attr/selectableItemBackground"
    app:tabIndicatorColor="@color/app_yellow"
    app:tabIndicatorHeight="4dip"
    android:layout_height="wrap_content"/>

I just added following lines

android:background="@color/colorPrimary"

app:tabBackground="?attr/selectableItemBackground"

like image 29
Munish Kapoor Avatar answered Oct 21 '22 01:10

Munish Kapoor