Android自定义View相关总结
继承View重写onDraw方法 通常用于实现复杂的、不规则的效果,需要自己支持wrap_content和padding。自定义圆形进度条组件的kotlin代码 class MyCircleProgress : View { private var mWidth = 0 private var mHeight = 0 private var progress = 0.6 constructor ( context : Context ) : super ( context ) { } constructor ( context : Context , attr : AttributeSet ) : super ( context , attr ) { } private fun dp2px ( dp : Int ) : Int { return TypedValue . applyDimension ( TypedValue . COMPLEX_UNIT_DIP , dp . toFloat ( ) , Resources . getSystem ( ) . displayMetrics ) . toInt ( ) } override fun onMeasure ( widthMeasureSpec : Int , heightMeasureSpec : Int ) {