Android examples for App:Resource
Resolves a color resource.
import android.content.Context; import android.graphics.Color; import android.os.Build; import android.support.annotation.ColorInt; import android.support.annotation.ColorRes; public class Main{ /**/*ww w . j ava2 s . c o m*/ * Resolves a color resource. * * @param color the color resource * @param context the current context * @return a color int */ public static @ColorInt int resolveColor(@ColorRes int color, Context context) { if (Build.VERSION.SDK_INT >= 23) { return context.getResources().getColor(color, context.getTheme()); } else { return context.getResources().getColor(color); } } }