Tomas
Tomas

Reputation: 1667

How to show only the indicator in TabLayout?

I use Android Tab Example for navigation.

<android.support.design.widget.TabLayout
        android:id="@+id/tab_layout"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:layout_above="@+id/lay_bot"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:background="?attr/colorPrimary"
        android:elevation="4dp"
        app:tabIndicatorColor="@color/tabIndicatorColor"
        app:tabIndicatorHeight="6dp"
        app:tabMaxWidth="0dp"
        app:tabTextColor="@android:color/holo_green_light" /> 

And i have next tabs:
enter image description here

But, i don't know how to show tabs indicator only (without text of tabs). For exampe:enter image description here

If you know how to do it, can you help me?

Upvotes: 0

Views: 1104

Answers (2)

user9214707
user9214707

Reputation:

Replace following line

android:layout_height="?attr/actionBarSize"

With

android:layout_height="6dp"

And make sure that u don't provide tab names.

Upvotes: 3

SpiritCrusher
SpiritCrusher

Reputation: 21043

Just set the height as same as indicator height and pass empty String as page title(Not neccesary).

<android.support.design.widget.TabLayout
    android:id="@+id/tab_layout"
    android:layout_width="match_parent"
    android:layout_height="6dp"
    android:layout_above="@+id/lay_bot"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:background="?attr/colorPrimary"
    android:elevation="4dp"
    app:tabIndicatorColor="@color/tabIndicatorColor"
    app:tabIndicatorHeight="6dp"
    app:tabMaxWidth="0dp"
    app:tabTextColor="@android:color/holo_green_light" /> 

Upvotes: 0

Related Questions