public static int [ ] getColorsFromArrayRes ( Resources resources , int resId ) { try { @ SuppressLint ( "Recycle" ) TypedArray array = resources . obtainTypedArray ( resId ) ; if ( array . length ( ) > 0 ) { final int len = array . length ( ) ; final int [ ] colors = new int [ len ] ; for ( int i = 0 ; i < len ; i ++ ) { colors [ i ] = array . getColor ( i , 0 ) ; } return colors ; } } catch ( Resources . NotFoundException ignored ) { } return null ; }
Get color array values form array resource