Android examples for Graphics:Color Value
Returns an int array with the color values for the given attributes (R.attr).
//package com.java2s; import android.content.Context; import android.content.res.Resources; import android.util.TypedValue; public class Main { /**//from ww w.ja v a 2 s . c o m * Returns an int array with the color values for the given attributes (R.attr). * Any unresolved colors will be represented by -1 */ public static int[] getThemeColorIDs(final Context context, final int[] attrs) { int[] colors = new int[attrs.length]; Resources.Theme theme = context.getTheme(); for (int i = 0; i < attrs.length; i++) { TypedValue typedValue = new TypedValue(); if (theme.resolveAttribute(attrs[i], typedValue, true)) { colors[i] = typedValue.data; } else { colors[i] = -1; } } return colors; } }