Add segments to your app easily and dynamically.
allprojects {
repositories {
jcenter()
}
}
implementation 'com.techhelper.segment:AndroidSegment:1.0.0'
<com.techhelper.segment.Segment
android:id="@+id/segments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
app:segmentBackgroundColor="#007AF3"
app:segmentTextColor="@android:color/white"
app:segmentTextSize="10sp" />
private void setupSegment() {
Segment segment = (Segment) findViewById(R.id.segments);
List<String> segmentTitles = Arrays.asList("Seg A", "Seg B", "Seg C");
segment.setTitles(segmentTitles);
segment.setSegmentChecked(0, true);
}
segment.setOnSegmentCheckedChangedListener(this);
@Override
public void onSegmentCheckedChanged(int position, CompoundButton buttonView, boolean isChecked) {
Toast.makeText(this, "Segment selected " + position, Toast.LENGTH_SHORT).show();
}
Please feel free to contribute by following standard process of reviewing pull requests and other git commands.
This project is licensed under the [Apache-2.0] - see the LICENSE file for details