private void obtainBackgroundColor ( final int theme ) { TypedArray typedArray = getContext ( ) . getTheme ( ) . obtainStyledAttributes ( theme , new int [ ] { R . attr . colorPrimary } ) ; int colorPrimary = typedArray . getColor ( 0 , 0 ) ; typedArray . recycle ( ) ; if ( colorPrimary != 0 ) { backgroundView . setBackgroundColor ( colorPrimary ) ; } }
Obtains the color of the toolbar s background from a specific typed array .