🐑 An adaptive and lightweight tab layout for Android 🐑
- Add
AustinTabView
to a layout file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<me.austinng.austintab.AustinTabView
android:id="@+id/austinTabView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:indicator_style="SEGMENTED_CONTROL"
app:tab_container_padding="4dp"
app:tab_style="ADAPTIVE"
app:tab_badge_font="@font/ubuntu_medium"
app:tab_text_font_active="@font/ubuntu_medium"
app:tab_text_font_inactive="@font/ubuntu_regular" />
</LinearLayout>
- In your activity
austinTabView.setData(
listOf(
TabData("Home", icon = R.drawable.ic_home),
TabData("Notifications", badge = "3"),
TabData("Profile"),
)
)
austinTabView.setTabSelectedListener { index ->
Log.d("AustinTabView", "Index $index selected")
}
austinTabView.setTabReselectedListener { index ->
Log.d("AustinTabView", "Index $index reselected")
}
austinTabView.setTabUnSelectedListener { index ->
Log.d("AustinTabView", "Index $index unselected")
}
You can find additional examples of usage and customization here.
- Add
Jitpack Repository
to yoursettings.gradle
file:
maven { url 'https://jitpack.io' }
- In your app’s
build.gradle
file, add the dependency:
dependencies {
implementation 'com.github.austin17ng:austin-tab:1.0.0'
}
setData(data: List<TabData>)
setTabSelectedListener(listener: (index: Int) -> Unit)
setTabReselectedListener(listener: (index: Int) -> Unit)
setTabUnSelectedListener(listener: (index: Int) -> Unit)
attachWithViewPager2(viewPager2: ViewPager2)
getIndex(): Int
setIndex(index: Int)
Feel free to contribute by submitting issues or pull requests. And please ensure that all pull requests are checked out from the master
branch.
Austin Tab is licensed under the MIT License.