我有一个带有2个选项卡的TabLayout的以下片段。每个选项卡都填充有一个点,以表示viewpager中的页面。
如何设置两个带有内点的制表符之间的间距/填充/边距?
我尝试了几件事,但对我没有用。
感谢您的帮助:)
fragment.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.viewpager.widget.ViewPager
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/pager"
/>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabDots"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="7.5dp"
app:tabBackground="@drawable/dot_selector"
app:tabGravity="center"
app:tabIndicatorHeight="0dp"
android:layout_marginBottom="20dp"
app:tabMaxWidth="7.5dp"
/>
</RelativeLayout>
dot_selector.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/dot_selected"
android:state_selected="true"/>
<item android:drawable="@drawable/dot_default" />
</selector>
dot_selected.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape
android:innerRadius="0dp"
android:shape="rectangle"
android:useLevel="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/colorBlack"/>
<corners android:radius="1000dp"/>
</shape>
dot_default.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape
android:innerRadius="0dp"
android:shape="rectangle"
android:useLevel="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/colorGrey"/>
<corners android:radius="1000dp"/>
</shape>
使用填充:
app:tabPaddingStart="10dp"
app:tabPaddingEnd="10dp"