Example usage for android.content.res TypedArray getDrawable

List of usage examples for android.content.res TypedArray getDrawable

Introduction

In this page you can find the example usage for android.content.res TypedArray getDrawable.

Prototype

@Nullable
public Drawable getDrawable(@StyleableRes int index) 

Source Link

Document

Retrieve the Drawable for the attribute at index.

Usage

From source file:com.lgh.tool.myview.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs) {
    super(context, attrs);
    setHorizontalScrollBarEnabled(false); //??????
    removeAllViews();//w  w  w .j  a v  a 2s. c o m
    if (attrs != null) {
        TypedArray attrsTypedArray = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
        if (attrsTypedArray != null) {
            allowWidthFull = attrsTypedArray.getBoolean(R.styleable.PagerSlidingTabStrip_allowWidthFull, false);
            slidingBlockDrawable = attrsTypedArray.getDrawable(R.styleable.PagerSlidingTabStrip_slidingBlock);
            disableViewPager = attrsTypedArray.getBoolean(R.styleable.PagerSlidingTabStrip_disableViewPager,
                    false);
            disableTensileSlidingBlock = attrsTypedArray
                    .getBoolean(R.styleable.PagerSlidingTabStrip_disableTensileSlidingBlock, false);
            attrsTypedArray.recycle();
        }
    }
}

From source file:com.arksh.summer.ui.zone.widget.ExpandableTextView.java

/**
 * ?/*from www . j  a  v a 2  s.  com*/
 * @param attrs
 */
private void init(AttributeSet attrs) {
    mCollapsedStatus = new SparseBooleanArray();

    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ExpandableTextView);
    mMaxCollapsedLines = typedArray.getInt(R.styleable.ExpandableTextView_maxCollapsedLines,
            MAX_COLLAPSED_LINES);
    mAnimationDuration = typedArray.getInt(R.styleable.ExpandableTextView_animDuration, DEFAULT_ANIM_DURATION);
    mExpandDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_expandDrawable);
    mCollapseDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_collapseDrawable);

    textCollapse = typedArray.getString(R.styleable.ExpandableTextView_textCollapse);
    textExpand = typedArray.getString(R.styleable.ExpandableTextView_textExpand);
    showExpandCollapseDrawable = typedArray
            .getBoolean(R.styleable.ExpandableTextView_showExpandCollapseDrawable, true);

    if (showExpandCollapseDrawable) {
        if (mExpandDrawable == null) {
            mExpandDrawable = ContextCompat.getDrawable(getContext(), R.drawable.icon_green_arrow_down);
        }
        if (mCollapseDrawable == null) {
            mCollapseDrawable = ContextCompat.getDrawable(getContext(), R.drawable.icon_green_arrow_up);
        }
    }

    if (TextUtils.isEmpty(textCollapse)) {
        textCollapse = getContext().getString(R.string.shink);
    }
    if (TextUtils.isEmpty(textExpand)) {
        textExpand = getContext().getString(R.string.expand);
    }
    contentTextColor = typedArray.getColor(R.styleable.ExpandableTextView_contentTextColor,
            ContextCompat.getColor(getContext(), R.color.light_gray));
    contentTextSize = typedArray.getDimension(R.styleable.ExpandableTextView_contentTextSize,
            DisplayUtil.sp2px(14));

    collapseExpandTextColor = typedArray.getColor(R.styleable.ExpandableTextView_collapseExpandTextColor,
            ContextCompat.getColor(getContext(), R.color.main_color));
    collapseExpandTextSize = typedArray.getDimension(R.styleable.ExpandableTextView_collapseExpandTextSize,
            DisplayUtil.sp2px(14));

    grarity = typedArray.getInt(R.styleable.ExpandableTextView_collapseExpandGrarity, Gravity.LEFT);

    typedArray.recycle();
    // enforces vertical orientation
    setOrientation(LinearLayout.VERTICAL);
    // default visibility is gone
    setVisibility(GONE);
}

From source file:com.findme.views.ExpandableTextView.java

private void init(AttributeSet attrs) {
    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ExpandableTextView);
    mMaxCollapsedLines = typedArray.getInt(R.styleable.ExpandableTextView_maxCollapsedLines,
            MAX_COLLAPSED_LINES);/*  ww  w . j av  a2s  .c om*/
    mAnimationDuration = typedArray.getInt(R.styleable.ExpandableTextView_animDuration, DEFAULT_ANIM_DURATION);
    mAnimAlphaStart = typedArray.getFloat(R.styleable.ExpandableTextView_animAlphaStart,
            DEFAULT_ANIM_ALPHA_START);
    mExpandDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_expandDrawable);
    mCollapseDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_collapseDrawable);

    if (mExpandDrawable == null) {
        mExpandDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_action_expand, null);
    }
    if (mCollapseDrawable == null) {
        mCollapseDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_action_collapse, null);
    }

    typedArray.recycle();
}

From source file:com.aibasis.parent.widget.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs) {
    super(context, attrs);
    setHorizontalScrollBarEnabled(false); // ??????

    if (attrs != null) {
        TypedArray attrsTypedArray = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
        if (attrsTypedArray != null) {
            allowWidthFull = attrsTypedArray.getBoolean(R.styleable.PagerSlidingTabStrip_allowWidthFull, false);
            slidingBlockDrawable = attrsTypedArray.getDrawable(R.styleable.PagerSlidingTabStrip_slidingBlock);
            disableViewPager = attrsTypedArray.getBoolean(R.styleable.PagerSlidingTabStrip_disableViewPager,
                    false);/*w ww . j ava  2s.  co  m*/
            attrsTypedArray.recycle();
        }
    }
}

From source file:com.mfh.enjoycity.view.CategorySlidingTabStrip.java

public CategorySlidingTabStrip(Context context, AttributeSet attrs) {
    super(context, attrs);
    setHorizontalScrollBarEnabled(false); // ??????

    if (attrs != null) {
        TypedArray attrsTypedArray = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
        if (attrsTypedArray != null) {
            allowWidthFull = attrsTypedArray.getBoolean(R.styleable.PagerSlidingTabStrip_allowWidthFull, false);
            slidingBlockDrawable = attrsTypedArray.getDrawable(R.styleable.PagerSlidingTabStrip_slidingBlock);
            disableViewPager = attrsTypedArray.getBoolean(R.styleable.PagerSlidingTabStrip_disableViewPager,
                    false);/* w  ww . j  ava 2  s . c  o  m*/
            attrsTypedArray.recycle();
        }
    }
}

From source file:com.prettygirl.avgallery.components.FixedTabsView.java

public FixedTabsView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);

    this.mContext = context;

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerExtensions, defStyle, 0);

    mDividerColor = a.getColor(R.styleable.ViewPagerExtensions_dividerColor, mDividerColor);

    mDividerMarginTop = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_dividerMarginTop,
            mDividerMarginTop);/*from  w  w w  .ja v  a  2  s. c  o m*/
    mDividerMarginBottom = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_dividerMarginBottom,
            mDividerMarginBottom);

    mDividerVisibility = a.getInt(R.styleable.ViewPagerExtensions_dividerVisibility, View.VISIBLE);

    mDividerDrawable = a.getDrawable(R.styleable.ViewPagerExtensions_dividerDrawable);

    a.recycle();

    this.setOrientation(LinearLayout.HORIZONTAL);
}

From source file:com.egoistk.trends.widget.SlidingPagerTabStrip.java

public SlidingPagerTabStrip(Context context, AttributeSet attrs) {
    super(context, attrs);
    setHorizontalScrollBarEnabled(false); // ??????

    if (attrs != null) {
        TypedArray attrsTypedArray = context.obtainStyledAttributes(attrs, R.styleable.SlidingPagerTabStrip);
        if (attrsTypedArray != null) {
            allowWidthFull = attrsTypedArray.getBoolean(R.styleable.SlidingPagerTabStrip_allowWidthFull, false);
            slidingBlockDrawable = attrsTypedArray.getDrawable(R.styleable.SlidingPagerTabStrip_slidingBlock);
            disableViewPager = attrsTypedArray.getBoolean(R.styleable.SlidingPagerTabStrip_disableViewPager,
                    false);//ww w .j av a2  s. c o  m
            attrsTypedArray.recycle();
        }
    }
}

From source file:com.cp.mylibrary.custom.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs) {
    super(context, attrs);
    setHorizontalScrollBarEnabled(false); // ??????

    if (attrs != null) {
        TypedArray attrsTypedArray = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
        if (attrsTypedArray != null) {
            allowWidthFull = attrsTypedArray.getBoolean(R.styleable.PagerSlidingTabStrip_allowWidthFull, false);

            slidingBlockDrawable = attrsTypedArray.getDrawable(R.styleable.PagerSlidingTabStrip_slidingBlock);
            disableViewPager = attrsTypedArray.getBoolean(R.styleable.PagerSlidingTabStrip_disableViewPager,
                    false);/* w  ww  .  jav  a 2 s .c o  m*/
            attrsTypedArray.recycle();
        }
    }
}

From source file:com.cicada.startup.common.ui.view.indicator.ViewPagerIndicator.java

public ViewPagerIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);
    setHorizontalScrollBarEnabled(false); // ??????
    scroller = new Scroller(context);

    if (attrs != null) {
        TypedArray attrsTypedArray = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerIndicator);
        if (attrsTypedArray != null) {
            allowWidthFull = attrsTypedArray.getBoolean(R.styleable.ViewPagerIndicator_allowWidthFull, false);
            slidingBlockDrawable = attrsTypedArray.getDrawable(R.styleable.ViewPagerIndicator_slidingBlock);
            slidingBlockHeight = (int) attrsTypedArray
                    .getDimension(R.styleable.ViewPagerIndicator_slidingBlockHeight, 8);
            disableViewPager = attrsTypedArray.getBoolean(R.styleable.ViewPagerIndicator_disableViewPager,
                    false);/*from   www  .  ja v a2 s .c o m*/
            attrsTypedArray.recycle();
        }
    }
}

From source file:com.mfh.litecashier.ui.widget.TopSlidingTabStrip.java

public TopSlidingTabStrip(Context context, AttributeSet attrs) {
    super(context, attrs);
    setHorizontalScrollBarEnabled(false); // ??????

    if (attrs != null) {
        TypedArray attrsTypedArray = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
        if (attrsTypedArray != null) {
            allowWidthFull = attrsTypedArray.getBoolean(R.styleable.PagerSlidingTabStrip_allowWidthFull, false);
            slidingBlockDrawable = attrsTypedArray.getDrawable(R.styleable.PagerSlidingTabStrip_slidingBlock);
            disableViewPager = attrsTypedArray.getBoolean(R.styleable.PagerSlidingTabStrip_disableViewPager,
                    false);//from w w  w  . j  a v  a2 s . com
            attrsTypedArray.recycle();
        }
    }
}