自定义控件-EvaluationView

作者: javalong | 来源:发表于2018-06-19 16:27 被阅读164次

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

效果

Screenshot_20180619-161319.jpg

使用

(具体代码可在github上看,有demo)

  1. 非xml
 EvaluationView.Builder()
    .bitmapToShapeSpace(arrayOf(70, 50, 50, 50, 50))
    .polygonNum(5)
    .maxScore(4)
    .iconSize(60.0f)
    .textToBitmapSpace(40.0f)
    .lineColor(Color.parseColor("#00FF00"))
    .lineWidth(4.0f)
    .shaderHandler(PointShaderHandler())
    .build(this@EvaluationActivity)
    .attachTo(flContent)
    .initData(iconArr2, titleArr2, scoreArr2)
  1. xml
  <com.javalong.customview.lib.EvaluationView
        android:id="@+id/evaluationView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        app:jcl_Evalueation_bitmapToShapeSpace="@array/jcl_EvaluationView_bitmapToShapeSpace"
        app:jcl_Evalueation_polygonNum="4" />

所有可配置参数

  1. 非xml
//多边形的中心到每个点长度,相当于半径
        fun sideLength(sideLength: Float): Builder {
            this.sideLength = sideLength
            return this
        }

        //几边形
        fun polygonNum(polygonNum: Int): Builder {
            this.polygonNum = polygonNum
            return this
        }

        //icon大小
        fun iconSize(iconSize: Float): Builder {
            this.iconSize = iconSize
            return this
        }

        //文字距离icon的距离
        fun textToBitmapSpace(textToBitmapSpace: Float): Builder {
            this.textToBitmapSpace = textToBitmapSpace
            return this
        }

        //最大分值
        fun maxScore(maxScore: Int): Builder {
            this.maxScore = maxScore
            return this
        }

        //线的颜色
        fun lineColor(lineColor: Int): Builder {
            this.lineColor = lineColor
            return this
        }

        //线的宽度
        fun lineWidth(lineWidth: Float): Builder {
            this.lineWidth = lineWidth
            return this
        }

        //渐变填充器
        fun shaderHandler(shaderHandler: ShaderHandler): Builder {
            this.shaderHandler = shaderHandler
            return this
        }

        //字体颜色
        fun textColor(textColor: Int): Builder {
            this.textColor = textColor
            return this
        }

        //字体大小
        fun textSize(textSize: Float): Builder {
            this.textSize = textSize
            return this
        }

        //中心的填充的颜色
        fun shapeColor(shapeColor: Int): Builder {
            this.shapeColor = shapeColor
            return this
        }

        //icon距离多边形的距离,数组,代表每个点距离多边形的距离s
        fun bitmapToShapeSpace(bitmapToShapeSpace: Array<Int>): Builder {
            this.bitmapToShapeSpace = bitmapToShapeSpace
            return this
        }
  1. xml
<declare-styleable name="jcl_Evalueation">
        <!--多边形的中心到每个点长度,相当于半径-->
        <attr name="jcl_Evalueation_sideLength" format="dimension|reference" />
        <!--线的颜色-->
        <attr name="jcl_Evalueation_lineColor" format="color|reference" />
        <!--字体的颜色-->
        <attr name="jcl_Evalueation_textColor" format="color|reference" />
        <!--中心的填充的颜色-->
        <attr name="jcl_Evalueation_shapeColor" format="color|reference" />
        <!--线的宽度-->
        <attr name="jcl_Evalueation_lineWidth" format="dimension|reference" />
        <!--字体的大小-->
        <attr name="jcl_Evalueation_textSize" format="dimension|reference" />
        <!--icon的大小-->
        <attr name="jcl_Evalueation_iconSize" format="dimension|reference" />
        <!--几边行-->
        <attr name="jcl_Evalueation_polygonNum" format="integer" />
        <!--icon距离多边形的距离,数组,代表每个点距离多边形的距离-->
        <attr name="jcl_Evalueation_bitmapToShapeSpace" format="reference" />
        <!--文字距离icon的距离-->
        <attr name="jcl_Evalueation_textToBitmapSpace" format="dimension|reference" />
    </declare-styleable>

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

相关文章

网友评论

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

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