Java Code Examples for android.support.v7.widget.TintTypedArray#obtainStyledAttributes()

The following examples show how to use android.support.v7.widget.TintTypedArray#obtainStyledAttributes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KyToolBar.java    From BitkyShop with MIT License 6 votes vote down vote up
public KyToolBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);

  initView();
  final TintTypedArray a =
      TintTypedArray.obtainStyledAttributes(getContext(), attrs, R.styleable.KyToolbar,
          defStyleAttr, 0);
  final boolean enableKyNavigationIcon =
      a.getBoolean(R.styleable.KyToolbar_enableKyNavigationIcon, true);
  final boolean enableKySearch = a.getBoolean(R.styleable.KyToolbar_enableKySearch, false);
  final Drawable navIcon = a.getDrawable(R.styleable.KyToolbar_KyNavigationIcon);
  final Drawable rightButtonIcon = a.getDrawable(R.styleable.KyToolbar_setRightButton);
  final String rightText = a.getString(R.styleable.KyToolbar_setRightText);

  setNavigationIcon(navIcon);
  setRightButtonIcon(rightButtonIcon);
  enableKyNavigation(enableKyNavigationIcon);
  setRightTextView(rightText);
  setEnabledSearch(enableKySearch);
  a.recycle();
}
 
Example 2
Source File: AppCompatTextViewHelper.java    From AndroidBase with Apache License 2.0 6 votes vote down vote up
public void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
    TintTypedArray a = TintTypedArray.obtainStyledAttributes(mView.getContext(), attrs,
            com.ljz.base.widget.R.styleable.SelectorInjection, defStyleAttr, 0);

    Drawable[] drawables = mView.getCompoundDrawables();
    try {
        int leftColor = a.getColor(com.ljz.base.widget.R.styleable.SelectorInjection_drawableLeftTint, DEFAULT_COLOR);
        int topColor = a.getColor(com.ljz.base.widget.R.styleable.SelectorInjection_drawableTopTint, DEFAULT_COLOR);
        int rightColor = a.getColor(com.ljz.base.widget.R.styleable.SelectorInjection_drawableRightTint, DEFAULT_COLOR);
        int bottomColor = a.getColor(com.ljz.base.widget.R.styleable.SelectorInjection_drawableBottomTint, DEFAULT_COLOR);

        int[] colors = {leftColor, topColor, rightColor, bottomColor};
        tintDrawable(drawables, colors);
    } finally {
        a.recycle();
    }
}
 
Example 3
Source File: MyToolBar.java    From Mobike with Apache License 2.0 6 votes vote down vote up
public MyToolBar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    initview();
    if (attrs != null) {

        final TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
                R.styleable.MyToolBar, defStyleAttr, 0);
        showSearchView = a.getBoolean(R.styleable.MyToolBar_showSearchView, false);
        left_button_icon = a.getDrawable(R.styleable.MyToolBar_leftButtonIcon);
        right_button_icon = a.getDrawable(R.styleable.MyToolBar_rightButtonIcon);
        title = a.getString(R.styleable.MyToolBar_myTitle);
        a.recycle();
    }

    isShouw();

    setContentInsetsRelative(10, 10);

    initListener();

}
 
Example 4
Source File: SkinCompatSeekBarHelper.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
@Override
    void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
        super.loadFromAttributes(attrs, defStyleAttr);

        TintTypedArray a = TintTypedArray.obtainStyledAttributes(mView.getContext(), attrs,
                R.styleable.AppCompatSeekBar, defStyleAttr, 0);
        mThumbResId = a.getResourceId(R.styleable.AppCompatSeekBar_android_thumb, INVALID_ID);
//        final Drawable drawable = a.getDrawableIfKnown(R.styleable.AppCompatSeekBar_android_thumb);
//        if (drawable != null) {
//            mView.setThumb(drawable);
//        }

//        mTickMarkResId = a.getResourceId(R.styleable.AppCompatSeekBar_tickMark, INVALID_ID);
//        final Drawable tickMark = a.getDrawable(R.styleable.AppCompatSeekBar_tickMark);
//        setTickMark(tickMark);

//        if (a.hasValue(R.styleable.AppCompatSeekBar_tickMarkTintMode)) {
//            mTickMarkTintMode = DrawableUtils.parseTintMode(a.getInt(
//                    R.styleable.AppCompatSeekBar_tickMarkTintMode, -1), mTickMarkTintMode);
//            mHasTickMarkTintMode = true;
//        }

//        if (a.hasValue(R.styleable.AppCompatSeekBar_tickMarkTint)) {
//            mTickMarkTintList = a.getColorStateList(R.styleable.AppCompatSeekBar_tickMarkTint);
//            mHasTickMarkTint = true;
//        }

        a.recycle();

//        applyTickMarkTint();
        applySkin();
    }
 
Example 5
Source File: BaseToolBar.java    From FileManager with Apache License 2.0 5 votes vote down vote up
public BaseToolBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mContext = context;
    initViews();
    setContentInsetsRelative(0, 0);
    if (attrs != null) {
        TintTypedArray array = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.BaseToolBar, defStyleAttr, 0);
        String leftText = array.getString(R.styleable.BaseToolBar_leftText);
        String centerText = array.getString(R.styleable.BaseToolBar_centerText);
        String rightText = array.getString(R.styleable.BaseToolBar_rightText);
        Drawable leftIcon = array.getDrawable(R.styleable.BaseToolBar_leftIcon);
        Drawable rightIcon = array.getDrawable(R.styleable.BaseToolBar_rightIcon);
        Drawable leftrightIcon = array.getDrawable(R.styleable.BaseToolBar_leftrightIcon);
        int leftSize = array.getInt(R.styleable.BaseToolBar_leftTextSize, DEFAULT_TEXT_SIZE);
        int rightSize = array.getInt(R.styleable.BaseToolBar_rightTextSize, DEFAULT_TEXT_SIZE);
        int centerSize = array.getInt(R.styleable.BaseToolBar_centerTextSize, DEFAULT_TEXT_SIZE);
        Drawable leftIconBackground = array.getDrawable(R.styleable.BaseToolBar_leftIconBackground);
        Drawable rightIconBackground = array.getDrawable(R.styleable.BaseToolBar_leftIconBackground);
        setLeftText(leftText);
        setCenterText(centerText);
        setRightText(rightText);
        setLeftIcon(leftIcon);
        setRightIcon(rightIcon);
        setLeftRightIcon(leftrightIcon);
        setLeftTextSize(leftSize);
        setRightTextSize(rightSize);
        setCenterTextSize(centerSize);
        setLeftIconBackground(leftIconBackground);
        setRightIconBackground(rightIconBackground);
        array.recycle();
    }
}
 
Example 6
Source File: SkinCompatImageHelper.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
    TintTypedArray a = null;
    try {
        a = TintTypedArray.obtainStyledAttributes(mView.getContext(), attrs,
                R.styleable.SkinCompatImageView, defStyleAttr, 0);

        mSrcResId = a.getResourceId(R.styleable.SkinCompatImageView_android_src, -1);
    } finally {
        if (a != null) {
            a.recycle();
        }
    }
    applySkin();
}
 
Example 7
Source File: SkinCompatCheckedTextView.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public SkinCompatCheckedTextView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
    mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
    mTextHelper = new SkinCompatTextHelper(this);
    mTextHelper.loadFromAttributes(attrs, defStyleAttr);

    TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
            TINT_ATTRS, defStyleAttr, 0);
    mCheckMarkResId = a.getResourceId(0, INVALID_ID);
    a.recycle();
    applyCheckMark();
}
 
Example 8
Source File: SkinCompatToolbar.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public SkinCompatToolbar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
    mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);

    TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
            R.styleable.Toolbar, defStyleAttr, 0);
    mNavigationIconResId = a.getResourceId(R.styleable.Toolbar_navigationIcon, INVALID_ID);

    int titleAp = a.getResourceId(R.styleable.Toolbar_titleTextAppearance, INVALID_ID);
    int subtitleAp = a.getResourceId(R.styleable.Toolbar_subtitleTextAppearance, INVALID_ID);
    a.recycle();
    if (titleAp != INVALID_ID) {
        a = TintTypedArray.obtainStyledAttributes(context, titleAp, R.styleable.SkinTextAppearance);
        mTitleTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
        a.recycle();
    }
    if (subtitleAp != INVALID_ID) {
        a = TintTypedArray.obtainStyledAttributes(context, subtitleAp, R.styleable.SkinTextAppearance);
        mSubtitleTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
        a.recycle();
    }
    a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
            R.styleable.Toolbar, defStyleAttr, 0);
    if (a.hasValue(R.styleable.Toolbar_titleTextColor)) {
        mTitleTextColorResId = a.getResourceId(R.styleable.Toolbar_titleTextColor, INVALID_ID);
    }
    if (a.hasValue(R.styleable.Toolbar_subtitleTextColor)) {
        mSubtitleTextColorResId = a.getResourceId(R.styleable.Toolbar_subtitleTextColor, INVALID_ID);
    }
    a.recycle();
    applyTitleTextColor();
    applySubtitleTextColor();
    applyNavigationIcon();
}
 
Example 9
Source File: SkinCompatTextHelper.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public void onSetTextAppearance(Context context, int resId) {
    final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context,
            resId, R.styleable.SkinTextAppearance);
    if (a.hasValue(R.styleable.SkinTextAppearance_android_textColor)) {
        mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
        SkinLog.d(TAG, "mTextColorResId = " + mTextColorResId);
    }
    if (a.hasValue(R.styleable.SkinTextAppearance_android_textColorHint)) {
        mTextColorHintResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColorHint, INVALID_ID);
        SkinLog.d(TAG, "mTextColorHintResId = " + mTextColorHintResId);
    }
    a.recycle();
    applySkin();
}
 
Example 10
Source File: SkinCompatTextHelper.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
    final Context context = mView.getContext();

    // First read the TextAppearance style id
    TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs,
            R.styleable.SkinCompatTextHelper, defStyleAttr, 0);
    final int ap = a.getResourceId(R.styleable.SkinCompatTextHelper_android_textAppearance, INVALID_ID);
    SkinLog.d(TAG, "ap = " + ap);
    a.recycle();

    if (ap != INVALID_ID) {
        a = TintTypedArray.obtainStyledAttributes(context, ap, R.styleable.SkinTextAppearance);
        if (a.hasValue(R.styleable.SkinTextAppearance_android_textColor)) {
            mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
            SkinLog.d(TAG, "mTextColorResId = " + mTextColorResId);
        }
        if (a.hasValue(R.styleable.SkinTextAppearance_android_textColorHint)) {
            mTextColorHintResId = a.getResourceId(
                    R.styleable.SkinTextAppearance_android_textColorHint, INVALID_ID);
            SkinLog.d(TAG, "mTextColorHintResId = " + mTextColorHintResId);
        }
        a.recycle();
    }

    // Now read the style's values
    a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.SkinTextAppearance,
            defStyleAttr, 0);
    if (a.hasValue(R.styleable.SkinTextAppearance_android_textColor)) {
        mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
        SkinLog.d(TAG, "mTextColorResId = " + mTextColorResId);
    }
    if (a.hasValue(R.styleable.SkinTextAppearance_android_textColorHint)) {
        mTextColorHintResId = a.getResourceId(
                R.styleable.SkinTextAppearance_android_textColorHint, INVALID_ID);
        SkinLog.d(TAG, "mTextColorHintResId = " + mTextColorHintResId);
    }
    a.recycle();
    applySkin();
}
 
Example 11
Source File: SkinCompatMultiAutoCompleteTextView.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public SkinCompatMultiAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
            TINT_ATTRS, defStyleAttr, 0);
    if (a.hasValue(0)) {
        mDropDownBackgroundResId = a.getResourceId(0, INVALID_ID);
    }
    a.recycle();
    applyDropDownBackgroundResource();
    mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
    mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
    mTextHelper = new SkinCompatTextHelper(this);
    mTextHelper.loadFromAttributes(attrs, defStyleAttr);
}
 
Example 12
Source File: SkinCompatAutoCompleteTextView.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public SkinCompatAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
            TINT_ATTRS, defStyleAttr, 0);
    if (a.hasValue(0)) {
        mDropDownBackgroundResId = a.getResourceId(0, INVALID_ID);
    }
    a.recycle();
    applyDropDownBackgroundResource();
    mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
    mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
    mTextHelper = new SkinCompatTextHelper(this);
    mTextHelper.loadFromAttributes(attrs, defStyleAttr);
}
 
Example 13
Source File: SkinCompatBackgroundHelper.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
    TintTypedArray a = TintTypedArray.obtainStyledAttributes(mView.getContext(), attrs,
            R.styleable.SkinBackgroundHelper, defStyleAttr, 0);
    try {
        if (a.hasValue(R.styleable.SkinBackgroundHelper_android_background)) {
            mBackgroundResId = a.getResourceId(
                    R.styleable.SkinBackgroundHelper_android_background, INVALID_ID);
        }
    } finally {
        a.recycle();
    }
    applySkin();
}
 
Example 14
Source File: SkinCompatProgressBarHelper.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
    TintTypedArray a = TintTypedArray.obtainStyledAttributes(mView.getContext(), attrs,
            TINT_ATTRS, defStyleAttr, 0);

    mIndeterminateDrawableResId = a.getResourceId(0, INVALID_ID);
    mProgressDrawableResId = a.getResourceId(1, INVALID_ID);

    a.recycle();
    applySkin();
}
 
Example 15
Source File: SkinCompatSpinner.java    From AndroidSkinAnimator with MIT License 4 votes vote down vote up
public SkinCompatSpinner(Context context, AttributeSet attrs, int defStyleAttr, int mode, Resources.Theme popupTheme) {
    super(context, attrs, defStyleAttr, mode, popupTheme);
    TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs,
            R.styleable.Spinner, defStyleAttr, 0);

    if (getPopupContext() != null) {
        if (mode == MODE_THEME) {
            if (Build.VERSION.SDK_INT >= 11) {
                // If we're running on API v11+ we will try and read android:spinnerMode
                TypedArray aa = null;
                try {
                    aa = context.obtainStyledAttributes(attrs, ATTRS_ANDROID_SPINNERMODE,
                            defStyleAttr, 0);
                    if (aa.hasValue(0)) {
                        mode = aa.getInt(0, MODE_DIALOG);
                    }
                } catch (Exception e) {
                    Log.i(TAG, "Could not read android:spinnerMode", e);
                } finally {
                    if (aa != null) {
                        aa.recycle();
                    }
                }
            } else {
                // Else, we use a default mode of dropdown
                mode = MODE_DROPDOWN;
            }
        }

        if (mode == MODE_DROPDOWN) {
            final TintTypedArray pa = TintTypedArray.obtainStyledAttributes(
                    getPopupContext(), attrs, R.styleable.Spinner, defStyleAttr, 0);
            mPopupBackgroundResId = pa.getResourceId(R.styleable.Spinner_android_popupBackground, INVALID_ID);
            pa.recycle();
        }
    }
    a.recycle();

    mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
    mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
}
 
Example 16
Source File: NumberAddSubView.java    From enjoyshop with Apache License 2.0 4 votes vote down vote up
public NumberAddSubView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mInflater = LayoutInflater.from(context);
    initView();

    if (attrs != null) {

        final TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
                R.styleable.NumberAddSubView, defStyleAttr, 0);


        int val = a.getInt(R.styleable.NumberAddSubView_value, 0);
        setValue(val);

        int maxVal = a.getInt(R.styleable.NumberAddSubView_maxValue, 0);
        if (maxVal != 0)
            setMaxValue(maxVal);

        int minVal = a.getInt(R.styleable.NumberAddSubView_minValue, 0);
        setMinValue(minVal);

        Drawable etBackground = a.getDrawable(R.styleable.NumberAddSubView_editBackground);
        if (etBackground != null)
            setEditTextBackground(etBackground);


        Drawable buttonAddBackground = a.getDrawable(R.styleable
                .NumberAddSubView_buttonAddBackgroud);
        if (buttonAddBackground != null)
            setButtonAddBackgroud(buttonAddBackground);

        Drawable buttonSubBackground = a.getDrawable(R.styleable
                .NumberAddSubView_buttonSubBackgroud);
        if (buttonSubBackground != null)
            setButtonSubBackgroud(buttonSubBackground);


        a.recycle();
    }
}
 
Example 17
Source File: EnjoyshopToolBar.java    From enjoyshop with Apache License 2.0 4 votes vote down vote up
public EnjoyshopToolBar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    this.context=context;

    initView();
    setContentInsetsRelative(10, 10);

    if (attrs != null) {
        final TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
                R.styleable.EnjoyshopToolBar, defStyleAttr, 0);

        final Drawable rightIcon = a.getDrawable(R.styleable.EnjoyshopToolBar_rightButtonIcon);
        if (rightIcon != null) {
            setRightButtonIcon(rightIcon);
        }

        boolean isShowSearchView = a.getBoolean(R.styleable.EnjoyshopToolBar_isShowSearchView,
                false);

        if (isShowSearchView) {
            showSearchView();
            hideTitleView();
        }

        CharSequence rightButtonText = a.getText(R.styleable.EnjoyshopToolBar_rightButtonText);
        if (rightButtonText != null) {
            setRightButtonText(rightButtonText);
        }

        boolean isShowLeft = a.getBoolean(R.styleable.EnjoyshopToolBar_isShowLeftIcon, false);
        if (isShowLeft) {
            setLeftIcon();
        }else{
            mLeftButton.setVisibility(GONE);
        }

        a.recycle();
    }

}
 
Example 18
Source File: CnToolbar.java    From ImitateTaobaoApp with Apache License 2.0 3 votes vote down vote up
@SuppressLint("RestrictedApi")
public CnToolbar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);



    initView();
    // toolbar两边边距
    setContentInsetsRelative(10,10);




    if(attrs !=null) {
        @SuppressLint("RestrictedApi") final TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
                R.styleable.CnToolbar, defStyleAttr, 0);


        @SuppressLint("RestrictedApi") final Drawable rightIcon = a.getDrawable(R.styleable.CnToolbar_rightButtonIcon);
        if (rightIcon != null) {
            //setNavigationIcon(navIcon);
            setRightButtonIcon(rightIcon);
        }


        @SuppressLint("RestrictedApi") boolean isShowSearchView = a.getBoolean(R.styleable.CnToolbar_isShowSearchView,false);
        if(isShowSearchView){
            showSearchView();
            hideTitleView();
        }


        a.recycle();
    }

}
 
Example 19
Source File: NumberAddSubView.java    From ImitateTaobaoApp with Apache License 2.0 2 votes vote down vote up
@SuppressLint("RestrictedApi")
public NumberAddSubView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mInflater = LayoutInflater.from(context);
    initView();

    if(attrs !=null){

        @SuppressLint("RestrictedApi") final TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
                R.styleable.NumberAddSubView, defStyleAttr, 0);


        @SuppressLint("RestrictedApi") int val =  a.getInt(R.styleable.NumberAddSubView_value,0);
        setValue(val);

        @SuppressLint("RestrictedApi") int maxVal = a.getInt(R.styleable.NumberAddSubView_maxValue,0);
        if(maxVal!=0)
            setMaxValue(maxVal);

        @SuppressLint("RestrictedApi") int minVal = a.getInt(R.styleable.NumberAddSubView_minValue,0);
        setMinValue(minVal);

        @SuppressLint("RestrictedApi") Drawable etBackground = a.getDrawable(R.styleable.NumberAddSubView_editBackground);
        if(etBackground!=null)
            setEditTextBackground(etBackground);


         @SuppressLint("RestrictedApi") Drawable buttonAddBackground = a.getDrawable(R.styleable.NumberAddSubView_buttonAddBackgroud);
         if(buttonAddBackground!=null)
             setButtonAddBackgroud(buttonAddBackground);

        @SuppressLint("RestrictedApi") Drawable buttonSubBackground = a.getDrawable(R.styleable.NumberAddSubView_buttonSubBackgroud);
        if(buttonSubBackground!=null)
            setButtonSubBackgroud(buttonSubBackground);




        a.recycle();
    }
}
 
Example 20
Source File: CNiaoToolBar.java    From ImitateTaobaoApp with Apache License 2.0 2 votes vote down vote up
@SuppressLint("RestrictedApi")
public CNiaoToolBar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);



    initView();
    setContentInsetsRelative(10,10);




    if(attrs !=null) {
        @SuppressLint("RestrictedApi") final TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
                R.styleable.CNiaoToolBar, defStyleAttr, 0);


        @SuppressLint("RestrictedApi") final Drawable rightIcon = a.getDrawable(R.styleable.CNiaoToolBar_rcightButtonIcon);
        if (rightIcon != null) {
            //setNavigationIcon(navIcon);
            setRightButtonIcon(rightIcon);
        }


        @SuppressLint("RestrictedApi") boolean isShowSearchView = a.getBoolean(R.styleable.CNiaoToolBar_icsShowSearchView,false);

        if(isShowSearchView){

            showSearchView();
            hideTitleView();

        }



        @SuppressLint("RestrictedApi") CharSequence rightButtonText = a.getText(R.styleable.CNiaoToolBar_rcightButtonText);
        if(rightButtonText !=null){
            setRightButtonText(rightButtonText);
        }



        a.recycle();
    }

}