private void parseAttrs ( Context context , AttributeSet attrs ) { if ( attrs != null ) { TypedArray typedArray = context . getTheme ( ) . obtainStyledAttributes ( attrs , R . styleable . BottomNavigationBar , 0 , 0 ) ; mActiveColor = typedArray . getColor ( R . styleable . BottomNavigationBar_bnbActiveColor , Utils . fetchContextColor ( context , R . attr . colorAccent ) ) ; mInActiveColor = typedArray . getColor ( R . styleable . BottomNavigationBar_bnbInactiveColor , Color . LTGRAY ) ; mBackgroundColor = typedArray . getColor ( R . styleable . BottomNavigationBar_bnbBackgroundColor , Color . WHITE ) ; mAutoHideEnabled = typedArray . getBoolean ( R . styleable . BottomNavigationBar_bnbAutoHideEnabled , true ) ; mElevation = typedArray . getDimension ( R . styleable . BottomNavigationBar_bnbElevation , getResources ( ) . getDimension ( R . dimen . bottom_navigation_elevation ) ) ; setAnimationDuration ( typedArray . getInt ( R . styleable . BottomNavigationBar_bnbAnimationDuration , DEFAULT_ANIMATION_DURATION ) ) ; switch ( typedArray . getInt ( R . styleable . BottomNavigationBar_bnbMode , MODE_DEFAULT ) ) { case MODE_FIXED : mMode = MODE_FIXED ; break ; case MODE_SHIFTING : mMode = MODE_SHIFTING ; break ; case MODE_FIXED_NO_TITLE : mMode = MODE_FIXED_NO_TITLE ; break ; case MODE_SHIFTING_NO_TITLE : mMode = MODE_SHIFTING_NO_TITLE ; break ; case MODE_DEFAULT : default : mMode = MODE_DEFAULT ; break ; } switch ( typedArray . getInt ( R . styleable . BottomNavigationBar_bnbBackgroundStyle , BACKGROUND_STYLE_DEFAULT ) ) { case BACKGROUND_STYLE_STATIC : mBackgroundStyle = BACKGROUND_STYLE_STATIC ; break ; case BACKGROUND_STYLE_RIPPLE : mBackgroundStyle = BACKGROUND_STYLE_RIPPLE ; break ; case BACKGROUND_STYLE_DEFAULT : default : mBackgroundStyle = BACKGROUND_STYLE_DEFAULT ; break ; } typedArray . recycle ( ) ; } else { mActiveColor = Utils . fetchContextColor ( context , R . attr . colorAccent ) ; mInActiveColor = Color . LTGRAY ; mBackgroundColor = Color . WHITE ; mElevation = getResources ( ) . getDimension ( R . dimen . bottom_navigation_elevation ) ; } }
This method initiates the bottomNavigationBar properties Tries to get them form XML if not preset sets them to their default values .