我试图添加色调到我的正常Textview
而不是AppCompatTextView
。我可以使用app:backgroundTint
为xml添加backgroundTint。有没有办法以编程方式为Textview
本身做同样的事情。(我的目标是kitkat支持)
注意:我有更多的Textview
。所以改变所有这些都将超过工作
setSupportButtonTintList
only适用于AppCompat
控件。setBackgroundTintList
没有显示kitkat的结果
注意
Added in version 23.1.1
所以你不能在19岁使用
对于AppCompat,您可以使用setSupportButtonTintList
void setSupportButtonTintList(ColorStateList tint)
tvOBJ.setSupportButtonTintList(ContextCompat.getColorStateList(CurrentActivity.this, R.color.your_color));
你可以使用ViewCompat.setBackgroundTintList()
val states = arrayOf(intArrayOf(android.R.attr.state_enabled))
val colors = intArrayOf(Color.RED)
val colorStateList = ColorStateList(states, colors)
ViewCompat.setBackgroundTintList(myView, colorStateList)