TextView.setTextColor()方法解读


问题:调用TextView.setTextColor(int colorResourceId)设置light_gray之后,字体颜色改变,设置其为black没有反应。

 

原因:Sets the text color for all the states (normal, selected, focused) to be this color.由于设置的不是colorResouceId,而是Color对应的,在不相同的情况下就不会改变其值。

 

解决办法:使用nameTextView.setTextColor(Color.parseColor(Constants.COLOR_BLACK));

 

f(viewHolder.nameFollowTextView.getTextColors()==ColorStateList.valueOf(Color.parseColor(Constants.COLOR_BLACK))){
            viewHolder.iconImageView.setImageBitmap(contact
                    .getContactPhotoBitmap());
        } else if (viewHolder.nameFollowTextView.getTextColors() == ColorStateList.valueOf(Color.parseColor(Constants.COLOR_LIGHT_GRAY))){
            Bitmap tempBitmap = BitmapUtils
                    .toGrayscale(contact.getContactPhotoBitmap());
            
            viewHolder.iconImageView.setImageBitmap(tempBitmap);
        }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM