自定义控件-StepView

github地址:
https://github.com/javalong/CustomView
喜欢的朋友,欢迎star,以后会不断添加一些好用的自定义控件哦!!

效果

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)

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


追加内容

由于评论中有人建议添加一个垂直方向的,所以添加了一个配置项
非xml

  //设置方向
  fun orientation(orientation: Int): Builder {
        this.orientation = orientation
        return this
   }
...
 var bottomStepView = StepView.Builder(this)
                .stepCount(5)
                .numTextSize(60.0f)
                .circleSize(80.0f)
                //链式写法,设置方向
                .orientation(StepView.VERTICAL)
                .build().attachTo(flContent,FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,FrameLayout.LayoutParams.WRAP_CONTENT))
        

xml

 <attr name="jcl_orientation" format="enum">
      <enum name="horizontal" value="1" />
       <enum name="vertical" value="2" />
 </attr>

...

 <com.javalong.customview.lib.view.StepView
                android:id="@+id/bottomStepView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                //直接设置
                app:jcl_orientation = "vertical"
                app:jcl_stepCount="5" />

效果

Screenshot_20180723-160225.jpg

有需求的朋友,可以直接在评论中回复,尽量满足大家的需求。github项目 CustomView希望能写一些常见的,好用的自定义view提供给大家。欢迎大家Star

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容