티스토리 뷰
Color 지정방법에 대한 다양한 방법 소개
You can use various functions from the Color
class to get the same effect of course.
holder.text.setTextColor(Color.RED);
Color.parseColor
(Manual) (like LEX uses)text.setTextColor(Color.parseColor("#FFFFFF"));
Color.rgb
andColor.argb
(Manual rgb) (Manual argb) (like Ganapathy uses)holder.text.setTextColor(Color.rgb(200,0,0)); holder.text.setTextColor(Color.argb(0,200,0,0));
And of course, if you want to define your color in an
XML
file, you can do this:<color name="errorColor">#f00</color>
because the
getColor()
function is deprecated1, you need to use it like so:ContextCompat.getColor(context, R.color.your_color);
You can also insert plain HEX, like so:
myTextView.setTextColor(0xAARRGGBB);
Where you have an alpha-channel first, then the color value.
Check out the complete manual of course, public class Color extends Object.
https://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String)
'Computer > Android' 카테고리의 다른 글
[Android] 특수문자 넣기 (0) | 2017.02.27 |
---|---|
[Android] View 절대 좌표값 (2) | 2017.02.21 |
[Android] 버튼 눌림 효과 (Button / ImageView) (0) | 2016.10.23 |
[Android] User-permission (권한설정) (0) | 2016.10.03 |
[Android] Alarm Ringtone 알람 링톤 선택하기 (0) | 2016.10.01 |
댓글