Android TabLayout With Border On Top

梦想的初衷 提交于 2020-06-02 12:43:12

问题


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).


回答1:


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"



回答2:


Use a custom ViewPager Strip.

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




回答3:


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>


来源:https://stackoverflow.com/questions/41626887/android-tablayout-with-border-on-top

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!