android动态改变textview文字颜色、imageview图片icon和背景图
android动态改变imageview图片icon
statusIv.setImageResource(R.drawable.xxx);
android动态改变背景图
tvName.setBackgroundResource(R.drawable.xxx);
tvName.setBackground(getResources().getDrawable(R.drawable.xxx));
android 动态更新文本颜色的设置、转换
textView.setTextColor(Color.RED);
textView.setTextColor(0xffff0000);
textView.setTextColor(Color.argb(127, 255, 0, 255));
textView.setTextColor(Color.parseColor("#00CCFF"))
textView.setTextColor(getResources().getColor(R.color.colorPrimary));//已过时
textView.setTextColor(ContextCompat.getColor(this, R.color.colorPrimary));//替换方法
参考:https://www.jianshu.com/p/e2bf7c34cd48
还没有评论,来说两句吧...