首页 > 解决方案 > 无法从自定义属性android获取值

问题描述

为什么总是默认值?

    private fun setupAttributes(attrs: AttributeSet?) {
        val typedArray = context.theme.obtainStyledAttributes(attrs, R.styleable.CustomView,
                0, 0)
        mColor = typedArray.getColor(R.styleable.CustomView_secondHandColor, Color.CYAN)
        paint.color = mColor
    }

标签: androidkotlincanvasandroid-custom-view

解决方案


推荐阅读