Tomero Indonesia
Tomero Indonesia

Reputation: 1695

Android TabLayout With Border On Top

I read documentation about TabLayout for add property to make border on top of TabLayout but I didn't find it anywhere in documentation.

So I want some trick to make TabLayout have border on top (or maybe at bottom).

Upvotes: 0

Views: 10552

Answers (3)

Tomero Indonesia
Tomero Indonesia

Reputation: 1695

Solved with this drawable xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <stroke
                android:width="1dp"
                android:color="#FFDDDDDD" />
            <solid android:color="#FFFFFFFF" />
        </shape>
    </item>
    <item
        android:top="1dp">
        <shape android:shape="rectangle">
            <stroke
                android:width="1dp"
                android:color="#FFFFFFFF" />
            <solid android:color="#00000000" />
        </shape>
    </item>
</layer-list>

and set into tablayout attribute/property:

android:background="@drawable/drawableName"

Upvotes: 3

Mel&#233;ndez
Mel&#233;ndez

Reputation: 47

you have to create a drawable, then call in this way

android:background="@drawable/yourShapeHere"

the drawable is looks like:

<?xml version="1.0" encoding="UTF-8"?>
  <shape xmlns:android="http://schemas.android.com/apk/res/android">
      <solid android:color="#FFFFFF"/>
      <stroke android:width="2dp" android:color="#515151"/>
      <corners android:radius="3dp" />
      <padding android:left="10dp" android:top="5dp" />
  </shape>

Upvotes: 1

slyidiot
slyidiot

Reputation: 78

Use a custom ViewPager Strip.

Try this: https://github.com/ogaclejapan/SmartTabLayout

Upvotes: 1

Related Questions