android动态改变textview文字颜色、imageview图片icon和背景图

怼烎@ 2023-07-24 14:41 64阅读 0赞

android动态改变imageview图片icon

  1. statusIv.setImageResource(R.drawable.xxx);

android动态改变背景图

  1. tvName.setBackgroundResource(R.drawable.xxx);
  2. tvName.setBackground(getResources().getDrawable(R.drawable.xxx));

android 动态更新文本颜色的设置、转换

  1. textView.setTextColor(Color.RED);
  2. textView.setTextColor(0xffff0000);
  3. textView.setTextColor(Color.argb(127, 255, 0, 255));
  4. textView.setTextColor(Color.parseColor("#00CCFF"))
  5. textView.setTextColor(getResources().getColor(R.color.colorPrimary));//已过时
  6. textView.setTextColor(ContextCompat.getColor(this, R.color.colorPrimary));//替换方法

参考:https://www.jianshu.com/p/e2bf7c34cd48

发表评论

表情:
评论列表 (有 0 条评论,64人围观)

还没有评论,来说两句吧...

相关阅读