android 分段选择,android-stepsview

本文详细介绍了如何在Android项目中通过build.gradle引入并使用StepsView库,并展示了如何通过链式调用方法高效设置视图属性,如颜色、步数、进度等。步骤包括设置标签、颜色和完成位置,适合快速上手Android UI定制。
摘要由CSDN通过智能技术生成

build.grade:allprojects {

repositories {

jcenter()

maven { url "https://jitpack.io" }

}

}

dependencies {

compile 'com.github.canner:android-stepsview:'

}

layout.xml

android:id="@+id/stepsView"

android:layout_width="match_parent"

android:layout_height="wrap_content"

/>

通过链式方法设置StepsView mStepsView = (StepsView) findViewById(R.id.stepview);

mStepsView.setLabels(steps)

.setBarColorIndicator(getContext().getResources().getColor(R.color.material_blue_grey_800))

.setProgressColorIndicator(getContext().getResources().getColor(R.color.orange))

.setLabelColorIndicator(getContext().getResources().getColor(R.color.orange))

.setCompletedPosition(0)

.drawView();

在布局中设置选项

xmlns:custom="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="wrap_content"

custom:labels="@array/labels2"      <====== set labels

custom:labelSize="20"     <================ set label size

custom:numOfSteps="5"     <================ set steps

custom:circleRadius="40"     <============= set radius

custom:progressMargin="150"     <========== set margin

custom:completePosition="2"     <========== set complete position

custom:barColor="@color/orange"     <====== set bar color

custom:labelColor="@color/red"     <======= set label color

custom:progressColor="@color/blue"     <=== set progress color

custom:progressTextColor="@color/black"  <= set progress text color

style="@style/stepsView"

/>

Options

我们可以使用链式调用的方法设置stepview,上面演示了部分方法,更多方法如下:

setLabels(String[] labels)

set labels

setBarColorIndicator(int ResId)

set bar color

setProgressColorIndicator(int ResId)

set progress color

setLabelColorIndicator(int ResId)

set label color

setCompletePosition(int pos)

set complete step position

setLabelTextSize(float size)

set label size

setProgressStrokeWidth(float width)

set the stroke width in between step progress.

setProgressMargins(float margin)

set margins of the view

setCircleRadius(float radius)

set the steps' radius.

setProgressTextColor(int textColor)

set text color in the step.

hideProgressText(boolean hide)

hide the text in the progress.

说明

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值