圆形标签布局

时间:2018-10-21 06:36:55

标签: android android-tablayout

enter image description here

如何在图像中获得这样的舍入标签布局

1 个答案:

答案 0 :(得分:1)

TabLayout中添加属性app:tabBackground="@drawable/capsule_sape" 看起来像这样

<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    app:tabBackground="@drawable/capsule_sape"
    app:tabGravity="fill"
    app:tabMode="scrollable"
    app:tabSelectedTextColor="@android:color/white"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

对于 capsule_shape ,请尝试使用代码

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
 <corners
  android:bottomLeftRadius="15dp"
  android:bottomRightRadius="15dp"
  android:topLeftRadius="15dp"
  android:topRightRadius="15dp" />
  <stroke
  android:width="10dp"
  android:color="@android:color/transparent"></stroke>
  <solid android:color="#FFAADD" />
</shape>