https://github.com/austin17ng/austin-tab
An adaptive and lightweight tab layout for Android
https://github.com/austin17ng/austin-tab
android segmentedcontrol tablayout
Last synced: 12 months ago
JSON representation
An adaptive and lightweight tab layout for Android
- Host: GitHub
- URL: https://github.com/austin17ng/austin-tab
- Owner: austin17ng
- License: mit
- Created: 2024-10-10T08:02:27.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-04-11T01:41:18.000Z (about 1 year ago)
- Last Synced: 2025-05-12T12:13:08.825Z (12 months ago)
- Topics: android, segmentedcontrol, tablayout
- Language: Kotlin
- Homepage:
- Size: 651 KB
- Stars: 36
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Austin Tab
:sheep: An adaptive and lightweight tab layout for Android :sheep:



## Examples
### A basic example
1. Add `AustinTabView` to a layout file
```
```
2. 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")
}
```
### Other examples
You can find additional examples of usage and customization [here](app/src/main/java/me/austinng/austintab).
## Anatomy

## Installation
1. Add `Jitpack Repository` to your `settings.gradle` file:
```
maven { url 'https://jitpack.io' }
```
2. In your app’s `build.gradle` file, add the dependency:
```
dependencies {
implementation 'com.github.austin17ng:austin-tab:1.0.0'
}
```
## List of attributes
| Attributes | Default value | Description |
| ------------- |:--------------------------------------------------------------------------------------------------------:|:-------------:|
| `offset` | `16dp` | Space between the tab and screen edges |
| `enable_auto_scroll` | `true` | Automatically centers the selected tab on the screen. |
| `enable_animation` | `false` | Enables tab translation animation |
| `tab_container_background` |  (for `TAB`),  (for `SEGMENTED`) | Background of the tab container |
| `tab_container_padding` | `0dp` | Padding for the tab container |
| `tab_style` | `ADAPTIVE` | Tab style: `ADAPTIVE` or `EQUAL` |
| `indicator_style` | `TAB` | Indicator style: `TAB` or `SEGMENTED_CONTROL` |
| `indicator_src` |  (for `TAB`),  (for `SEGMENTED`) | Drawable resource for the indicator|
|`indicator_height`| `2dp` |Height of the indicator (only for `indicator_style = TAB`)|
|`tab_vertical_padding`| `6dp` |Vertical padding for tabs|
|`tab_horizontal_padding`| `16dp` |Horizontal padding for tabs|
|`tab_text_color_active`|  (for `TAB`),  (for `SEGMENTED`) |Text color of the active tab|
|`tab_text_color_inactive`|  |Text color of inactive tabs|
|`tab_text_font_active`| `none` |Font for the active tab|
|`tab_text_font_inactive`| `none` |Font for inactive tabs|
|`tab_text_size`| `14sp` |Size of the tab text|
|`tab_icon_active_color`|  (for `TAB`),  (for `SEGMENTED`) |Color for the active tab icon|
|`tab_icon_inactive_color`|  |Color for the inactive tab icon|
|`tab_badge_text_size`| `10sp` |Text size of the badge|
|`tab_badge_font`| `none` |Font for the tab badge|
|`tab_badge_source`|  |Drawable resource for the badge|
|`tab_badge_color`|  |Text color of the badge|
|`tab_badge_position`| `TOP` |Position of the badge: `TOP`, `CENTER`, or `BOTTOM`|
## List of functions
`setData(data: List)`
`setTabSelectedListener(listener: (index: Int) -> Unit)`
`setTabReselectedListener(listener: (index: Int) -> Unit)`
`setTabUnSelectedListener(listener: (index: Int) -> Unit)`
`attachWithViewPager2(viewPager2: ViewPager2)`
`getIndex(): Int`
`setIndex(index: Int)`
## Contributing
Feel free to contribute by submitting issues or pull requests. And please ensure that all pull requests are checked out from the `master` branch.
## Related Projects
- [Austin Segmented Control](https://github.com/austin17ng/Austin_SegmentedControl) – 🐑 A segmented control (tabs) library for Jetpack Compose 🐑.
## License
Austin Tab is licensed under the MIT License.