TabLayout indicator is not visible

Viewed 40

I want to make custom shape as TabLayout indicator. It suppose to be circle around TabItem icon (like oval Button). But as I set it, for some reason, only icon color is changing and I cant see indicator at all.

TabLayout:

    <com.google.android.material.tabs.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:paddingTop="@dimen/padding_small"
        android:paddingBottom="@dimen/padding_medium"
        app:tabIndicatorGravity="center"
        app:tabIconTint="@color/tab_icon_tint"
        app:tabIndicator="@drawable/tab_indicator"
        app:tabRippleColor="@null">

        <com.google.android.material.tabs.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:icon="@drawable/tab_account_icon"/>

        <com.google.android.material.tabs.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <com.google.android.material.tabs.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </com.google.android.material.tabs.TabLayout>

tab_indicator.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval" >
    <solid android:color="@color/tab_selected" />
</shape>

I tried to change tab_indicator.xml initialization if it makes some difference (maybe it needs layer-list as input) but same result.

<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >

<item
    android:gravity="center">

    <shape
        android:shape="oval" >
        <solid android:color="@color/tab_selected" />
    </shape>

</item>

</layer-list>

Want to achieve this design(indicator is circle around tabIcon and should move while selecting tab to next tab):

enter image description here

0 Answers
Related