Skip to content Skip to sidebar Skip to footer

Is There Any Shortcut On Android Studio To Get The Hex Value Of Color From Text Or Something Like This?

I don't want to remember the color codes during coding. Is there is any shortcut to get the color codes from the color name or anything else to get the color code on Android Studio

Solution 1:

You can use a colors.xml where you store your colors. Then you can access them later in xml as @color/myGreen.

Here is a example xml:

<?xml version="1.0" encoding="utf-8"?><resources><colorname="my_green">#00cc00</color></resources>

If you need the color again as int you can use this code:

int color = context.getResources().getColor(R.color.my_green)

Or better to avoid deprecated methods:

Resourcesres= context.getResources();
intcolor= res.getColor(R.color.my_green, res.getTheme());

Post a Comment for "Is There Any Shortcut On Android Studio To Get The Hex Value Of Color From Text Or Something Like This?"