Skip to content

Instantly share code, notes, and snippets.

@Kalaiz
Last active December 17, 2020 13:15
Show Gist options
  • Save Kalaiz/b7a9337df5a6d7dfccd0ef94d4fd2e89 to your computer and use it in GitHub Desktop.
Save Kalaiz/b7a9337df5a6d7dfccd0ef94d4fd2e89 to your computer and use it in GitHub Desktop.
Simple Tab Layout XML Example
<?xml version="1.0" encoding="utf-8"?>
<--https://stackoverflow.com/questions/65078252/custom-tab-layout-with-viewpager2/65079234#65079234 -->
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".MainActivity">
<com.google.android.material.tabs.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.tabs.TabItem
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Tab 1" />
<com.google.android.material.tabs.TabItem
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Tab 2" />
<com.google.android.material.tabs.TabItem
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Tab 3" />
</com.google.android.material.tabs.TabLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment