@ Override public void applyDesign ( Design design , int themeColor ) { Context ctx = mInputField . getContext ( ) ; int smallPadId = design . isMaterial ( ) ? R . dimen . default_margin : R . dimen . default_margin_small ; int largePadId = design . isMaterial ( ) ? R . dimen . material_edittext_spacing : R . dimen . default_margin_small ; int padLR = ctx . getResources ( ) . getDimensionPixelSize ( largePadId ) ; int padTB = ctx . getResources ( ) . getDimensionPixelSize ( smallPadId ) ; FrameLayout . LayoutParams params = new FrameLayout . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , ViewGroup . LayoutParams . WRAP_CONTENT ) ; params . setMargins ( padLR , padTB , padLR , padTB ) ; mInputField . setLayoutParams ( params ) ; if ( design . isLight ( ) ) mInputField . setTextColor ( mInputField . getResources ( ) . getColor ( R . color . background_material_dark ) ) ; else mInputField . setTextColor ( mInputField . getResources ( ) . getColor ( R . color . background_material_light ) ) ; Drawable drawable ; if ( design . isMaterial ( ) ) { drawable = mInputField . getResources ( ) . getDrawable ( R . drawable . edittext_mtrl_alpha ) ; } else { drawable = mInputField . getBackground ( ) ; } drawable . setColorFilter ( themeColor , PorterDuff . Mode . SRC_ATOP ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . JELLY_BEAN ) mInputField . setBackground ( drawable ) ; else mInputField . setBackgroundDrawable ( drawable ) ; }
Apply a design to the style