SegmentedController is an Android UI library for using customizable RadioGroup with RadioButtons.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
...
//SegmentedController
implementation 'com.github.erayozenc:SegmentedController:1.0.0'
}
<com.erayozenc.lib.SegmentController
android:id="@+id/segmentedController"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:tab_cornerRadius="22dp"
app:tab_selectedColor="@color/white"
app:tab_unselectedColor="@color/light_grey"
app:tab_strokeWidth="4dp">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Second"/>
</com.erayozenc.lib.SegmentController>
<attr name="tab_strokeWidth" format="dimension"/>
<attr name="tab_cornerRadius" format="dimension"/>
<attr name="tab_selectedColor" format="color"/>
<attr name="tab_unselectedColor" format="color"/>
You can also customize your SegmentedController programmatically.
val segmentedController = findViewById<SegmentController>(R.id.segmentedController)
segmentedController.setSelectedTabColor(Color.WHITE)
segmentedController.setUnselectedTabColor(Color.GRAY)
segmentedController.setCornerRadius(22f)
segmentedController.setStrokeWidth(4f)
Default values for attributes
tab_strokeWidth = 2dp
tab_cornerRadius = 4dp
tab_selectedColor = Color.WHITE
tab_unselectedColor = Color.LTGRAY
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.