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