自定义控件-StepView

作者: javalong | 来源:发表于2018-06-15 17:08 被阅读36次

github地址:
https://github.com/javalong/CustomView

效果

Screenshot_20180615-165712.jpg

使用

  1. 非xml
var bottomStepView = StepView.Builder(this)
                .stepCount(4)
                .numTextSize(60.0f)
                .circleSize(80.0f)
                .build().attachTo(flContent)
 bottomBtNext.setOnClickListener({
            bottomStepView.next()
        })
        bottomBtPre.setOnClickListener({
            bottomStepView.pre()
        })
  1. xml
 <com.javalong.customview.lib.StepView
            android:id="@+id/topStempView"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            app:jcl_stepCount="5" />

  1. 上一步/下一步
    分别调用pre()/next()方法

  2. 所有的配置项
    xml可配置项

<declare-styleable name="jcl_StepView">
        <attr name="jcl_stepCount" format="integer" />
        <attr name="jcl_mainColor" format="color|reference" />
        <attr name="jcl_minorColor" format="color|reference" />
        <attr name="jcl_lineLength" format="dimension|reference" />
        <attr name="jcl_lineWidth" format="dimension|reference" />
        <attr name="jcl_circleSize" format="dimension|reference" />
        <attr name="jcl_numberTextSize" format="dimension|reference" />
    </declare-styleable>

builder模式可配置项

        //设置当前的步数
        fun stepCount(stepCount: Int)
        //设置连接线的长度
        fun lineLength(lineLength: Float)
        //设置连接线的粗细
        fun lineWidth(lineWidth: Float)
        //设置圆的直径
        fun circleSize(circleSize: Float)
        //设置数字字体的大小
        fun numTextSize(numTextSize: Float)
        //设置主色调
        fun mainColor(mainColor: Int)
        //设置次色调
        fun minorColor(minorColor: Int)

觉得还可以的话,帮忙点个赞兄弟。

相关文章

网友评论

  • RicoX2016:大佬,这个控件可以竖向排列不?
    javalong:@RicoX2016 还有什么自己需要的自定义view也可以留言,我想弄一个比较通用的自定义view集合
    RicoX2016:@javalong :+1: 期待
    javalong:可以做,要不我周一的时候改一下,再上传好了

本文标题:自定义控件-StepView

本文链接:https://www.haomeiwen.com/subject/cmpmeftx.html