Java tutorial
//package com.java2s; import android.content.Context; import android.content.res.TypedArray; import android.support.annotation.AttrRes; import android.support.annotation.NonNull; public class Main { public static int getThemeAttrColor(@NonNull Context context, @AttrRes int attr) { TypedArray a = context.obtainStyledAttributes(null, new int[] { attr }); try { return a.getColor(0, 0); } finally { a.recycle(); } } }