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

The following examples show how to use android.support.v7.widget.TintTypedArray#getDrawable() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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();
    }

}