Home

Awesome

Android Arsenal jitpack Build Status License Download

中文

a simple SegmentControl Widget

art2

art1

使用:

添加依赖到build.gradle:

dependencies {
    compile 'com.7heaven.widgets:segmentcontrol:1.17'
}

相关属性:

<com.sevenheaven.segmentcontrol.SegmentControl
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/segment_control"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp"                       	
    android:textSize="18sp"
	app:block_direction="horizontal"
    app:selectedColor="#32ADFF"
	app:normalColor="#FFFFFF"
    app:textColors="@color/text_colors"
    app:backgroundColors="@color/background_color"
    app:cornerRadius="5dp"
    app:separatorWidth="2dp"
    app:boundWidth="4dp"
    app:texts="啊啊|啦啦啦|哈哈哈|顶顶顶顶"
    app:verticalGap="10dp"
    app:horizonGap="10dp"/>

使用OnSegmentControlClickListener来监听选中的变换

mSegmentHorzontal = (SegmentControl) findViewById(R.id.segment_control);
mSegmentHorzontal.setOnSegmentControlClickListener(new SegmentControl.OnSegmentControlClickListener() {
    @Override
    public void onSegmentControlClick(int index) {
        Log.i(TAG, "onSegmentControlClick: index = " + index);
    }
});

English

a simple SegmentControl Widget

art2

art1

Usage:

add dependency to build.gradle:

dependencies {
    compile 'com.7heaven.widgets:segmentcontrol:1.16'
}

Attributes:

noticed that textColors & backgroundColors has higher priority than selectedColor & normalColor

<com.sevenheaven.segmentcontrol.SegmentControl
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/segment_control"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp"                       	
    android:textSize="18sp"
	app:block_direction="horizontal"
    app:selectedColor="#32ADFF"
	app:normalColor="#FFFFFF"
    app:textColors="@color/text_colors"
    app:backgroundColors="@color/background_color"
    app:cornerRadius="5dp"
    app:separatorWidth="2dp"
    app:boundWidth="4dp"
    app:texts="啊啊|啦啦啦|哈哈哈|顶顶顶顶"
    app:verticalGap="10dp"
    app:horizonGap="10dp"/>

using OnSegmentControlClickListener to listen to segment change event.

mSegmentHorzontal = (SegmentControl) findViewById(R.id.segment_control);
mSegmentHorzontal.setOnSegmentControlClickListener(new SegmentControl.OnSegmentControlClickListener() {
    @Override
    public void onSegmentControlClick(int index) {
        Log.i(TAG, "onSegmentControlClick: index = " + index);
    }
});