public static int fetchContextColor ( Context context , int androidAttribute ) { TypedValue typedValue = new TypedValue ( ) ; TypedArray a = context . obtainStyledAttributes ( typedValue . data , new int [ ] { androidAttribute } ) ; int color = a . getColor ( 0 , 0 ) ; a . recycle ( ) ; return color ; }
This method can be extended to get all android attributes color string dimension ... etc