'parseColor'에 해당되는 글 1건

  1. 2017.02.19 [Android] Color
2017.02.19 01:07

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)

  • Color.rgb and Color.argb (Manual rgb) (Manual argb) (like Ganapathy uses)

  • 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:


    Where you have an alpha-channel first, then the color value.

Check out the complete manual of course, public class Color extends Object.


Posted by injunech