<com.google.android.material.tabs.TabLayout
android:id="@+id/switchLayout"
android:layout_width="match_parent">
<com.google.android.material.tabs.TabItem
android:id="@+id/tab1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout="@layout/custom" />
<com.google.android.material.tabs.TabItem
android:id="@+id/tab2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout="@layout/custom" />
<com.google.android.material.tabs.TabItem
android:id="@+id/tab3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout="@layout/custom" />
</com.google.android.material.tabs.TabLayout>
设置禁用
touchableList = tabLayout?.touchables
touchableList?.forEach { it.isEnabled = false }