How to get accent color programmatically?

前端 未结 7 2364
没有蜡笔的小新
没有蜡笔的小新 2020-12-05 03:32

How would one fetch the accent color set in styles, like below, programmatically?

    @color/material_green_500<         


        
相关标签:
7条回答
  • 2020-12-05 04:31

    Kotlin solution:

        context.obtainStyledAttributes(TypedValue().data, intArrayOf(R.attr.colorAccent)).let {
            Log.d("AppLog", "color:${it.getColor(0, 0).toHexString()}")
            it.recycle()
        }
    
    0 讨论(0)
提交回复
热议问题