问题描述
我有两个组件。带有背景的 TextView 和带有矢量背景的 ImageView,我想根据某些操作更新颜色。
我有两个相应地更改颜色的函数,它们在正确的位置执行(我有一个 TextView 打印出当前调用的内容,结果如预期),但我发现它们通常不起作用正确 - 实际上我想要做的是更改我的文本视图的背景颜色并更改我的矢量资产的颜色,但是在使用 ViewCompact 时,它向我显示了错误的颜色结果,而 DrawableCompat 则向我显示了正确的结果。这不应该发生。 以下是功能:
显示错误颜色的代码。
ViewCompat.setBackgroundTintList(
itemViewHolder.logo,ColorStateList.valueOf(Color.parseColor(YELLOW_COLOR)))
显示正确结果的代码。
DrawableCompat.setTint(arrowSign.getDrawable(),ContextCompat.getColor(arrowSign.getContext(),R.color.orange));
DrawableCompat.setTint(button.getBackground(),ContextCompat.getColor(button.getContext(),R.color.darkBlack));
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)