private void initStyle(AttributeSet attributeSet,int defStyleAttribute){
  TypedArray typedArray=mContext.obtainStyledAttributes(attributeSet,R.styleable.MaterialSearchView,defStyleAttribute,0);
  if (typedArray != null) {
    if (typedArray.hasValue(R.styleable.MaterialSearchView_searchBackground)) {
      setBackground(typedArray.getDrawable(R.styleable.MaterialSearchView_searchBackground));
    }
    if (typedArray.hasValue(R.styleable.MaterialSearchView_android_textColor)) {
      setTextColor(typedArray.getColor(R.styleable.MaterialSearchView_android_textColor,ContextCompat.getColor(mContext,R.color.black)));
    }
    if (typedArray.hasValue(R.styleable.MaterialSearchView_android_textColorHint)) {
      setHintTextColor(typedArray.getColor(R.styleable.MaterialSearchView_android_textColorHint,ContextCompat.getColor(mContext,R.color.gray_50)));
    }
    if (typedArray.hasValue(R.styleable.MaterialSearchView_android_hint)) {
      setHint(typedArray.getString(R.styleable.MaterialSearchView_android_hint));
    }
    if (typedArray.hasValue(R.styleable.MaterialSearchView_searchVoiceIcon)) {
      setVoiceIcon(typedArray.getDrawable(R.styleable.MaterialSearchView_searchVoiceIcon));
    }
    if (typedArray.hasValue(R.styleable.MaterialSearchView_searchCloseIcon)) {
      setClearIcon(typedArray.getDrawable(R.styleable.MaterialSearchView_searchCloseIcon));
    }
    if (typedArray.hasValue(R.styleable.MaterialSearchView_searchBackIcon)) {
      setBackIcon(typedArray.getDrawable(R.styleable.MaterialSearchView_searchBackIcon));
    }
    if (typedArray.hasValue(R.styleable.MaterialSearchView_searchSuggestionBackground)) {
      setSuggestionBackground(typedArray.getResourceId(R.styleable.MaterialSearchView_searchSuggestionBackground,R.color.search_layover_bg));
    }
    if (typedArray.hasValue(R.styleable.MaterialSearchView_android_inputType)) {
      setInputType(typedArray.getInteger(R.styleable.MaterialSearchView_android_inputType,InputType.TYPE_CLASS_TEXT));
    }
    if (typedArray.hasValue(R.styleable.MaterialSearchView_searchBarHeight)) {
      setSearchBarHeight(typedArray.getDimensionPixelSize(R.styleable.MaterialSearchView_searchBarHeight,getAppCompatActionBarHeight()));
    }
 else {
      setSearchBarHeight(getAppCompatActionBarHeight());
    }
    ViewCompat.setFitsSystemWindows(this,typedArray.getBoolean(R.styleable.MaterialSearchView_android_fitsSystemWindows,false));
    typedArray.recycle();
  }
}

private void initStyle ( AttributeSet attributeSet , int defStyleAttribute ) { TypedArray typedArray = mContext . obtainStyledAttributes ( attributeSet , R . styleable . MaterialSearchView , defStyleAttribute , 0 ) ; if ( typedArray != null ) { if ( typedArray . hasValue ( R . styleable . MaterialSearchView_searchBackground ) ) { setBackground ( typedArray . getDrawable ( R . styleable . MaterialSearchView_searchBackground ) ) ; } if ( typedArray . hasValue ( R . styleable . MaterialSearchView_android_textColor ) ) { setTextColor ( typedArray . getColor ( R . styleable . MaterialSearchView_android_textColor , ContextCompat . getColor ( mContext , R . color . black ) ) ) ; } if ( typedArray . hasValue ( R . styleable . MaterialSearchView_android_textColorHint ) ) { setHintTextColor ( typedArray . getColor ( R . styleable . MaterialSearchView_android_textColorHint , ContextCompat . getColor ( mContext , R . color . gray_50 ) ) ) ; } if ( typedArray . hasValue ( R . styleable . MaterialSearchView_android_hint ) ) { setHint ( typedArray . getString ( R . styleable . MaterialSearchView_android_hint ) ) ; } if ( typedArray . hasValue ( R . styleable . MaterialSearchView_searchVoiceIcon ) ) { setVoiceIcon ( typedArray . getDrawable ( R . styleable . MaterialSearchView_searchVoiceIcon ) ) ; } if ( typedArray . hasValue ( R . styleable . MaterialSearchView_searchCloseIcon ) ) { setClearIcon ( typedArray . getDrawable ( R . styleable . MaterialSearchView_searchCloseIcon ) ) ; } if ( typedArray . hasValue ( R . styleable . MaterialSearchView_searchBackIcon ) ) { setBackIcon ( typedArray . getDrawable ( R . styleable . MaterialSearchView_searchBackIcon ) ) ; } if ( typedArray . hasValue ( R . styleable . MaterialSearchView_searchSuggestionBackground ) ) { setSuggestionBackground ( typedArray . getResourceId ( R . styleable . MaterialSearchView_searchSuggestionBackground , R . color . search_layover_bg ) ) ; } if ( typedArray . hasValue ( R . styleable . MaterialSearchView_android_inputType ) ) { setInputType ( typedArray . getInteger ( R . styleable . MaterialSearchView_android_inputType , InputType . TYPE_CLASS_TEXT ) ) ; } if ( typedArray . hasValue ( R . styleable . MaterialSearchView_searchBarHeight ) ) { setSearchBarHeight ( typedArray . getDimensionPixelSize ( R . styleable . MaterialSearchView_searchBarHeight , getAppCompatActionBarHeight ( ) ) ) ; } else { setSearchBarHeight ( getAppCompatActionBarHeight ( ) ) ; } ViewCompat . setFitsSystemWindows ( this , typedArray . getBoolean ( R . styleable . MaterialSearchView_android_fitsSystemWindows , false ) ) ; typedArray . recycle ( ) ; } }
initializes the style of this view .
