An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# Austin Tab
:sheep: An adaptive and lightweight tab layout for Android :sheep:

![Release](https://jitpack.io/v/austin17ng/austin-tab.svg)
![Monthly download statistics](https://jitpack.io/v/austin17ng/austin-tab/month.svg)

drawing

## 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

![Anatomy](/images/anatomy.png "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` | ![](/images/tab_bg.png "") (for `TAB`), ![](/images/segmented_bg.png "") (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` | ![](/images/tab_indicator.png "") (for `TAB`), ![](/images/segmented_indicator.png "") (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`| ![](/images/white.png "") (for `TAB`), ![](/images/black.png "") (for `SEGMENTED`) |Text color of the active tab|
|`tab_text_color_inactive`| ![](/images/black.png "") |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`| ![](/images/white.png "") (for `TAB`), ![](/images/black.png "") (for `SEGMENTED`) |Color for the active tab icon|
|`tab_icon_inactive_color`| ![](/images/black.png "") |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`| ![](/images/badge.png "") |Drawable resource for the badge|
|`tab_badge_color`| ![](/images/white.png "") |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.