private void obtainTitleColor ( final int theme ) { TypedArray typedArray = getContext ( ) . getTheme ( ) . obtainStyledAttributes ( theme , new int [ ] { android . R . attr . textColorPrimary } ) ; int textColorPrimary = typedArray . getResourceId ( 0 , 0 ) ; typedArray . recycle ( ) ; if ( textColorPrimary != 0 ) { int titleColor = ContextCompat . getColor ( getContext ( ) , textColorPrimary ) ; toolbar . setTitleTextColor ( titleColor ) ; } }
Obtains the color of the toolbar s title from a specific typed array .