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:android.support.design.internal.ScrimInsetsRelativeLayout.java

public ScrimInsetsRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr,
            R.style.Widget_Design_ScrimInsetsFrameLayout);
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground);
    a.recycle();/* ww w  . j  av  a 2 s .  c o m*/
    setWillNotDraw(true); // No need to draw until the insets are adjusted

    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            if (null == mInsets) {
                mInsets = new Rect();
            }
            mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                    insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
            setWillNotDraw(mInsets.isEmpty() || mInsetForeground == null);
            ViewCompat.postInvalidateOnAnimation(ScrimInsetsRelativeLayout.this);
            return insets.consumeSystemWindowInsets();
        }
    });
}

From source file:butter.droid.widget.ScrimInsetsFrameLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0);
    if (a == null) {
        return;//from  www . j av  a 2  s. c o m
    }
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForegroundColor);
    a.recycle();

    setWillNotDraw(true);
}

From source file:android.support.designox.internal.ScrimInsetsFrameLayout.java

public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr,
            R.style.Widget_Design_ScrimInsetsFrameLayout);
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground);
    a.recycle();/*from   w w w .ja v  a2  s  . c  o  m*/
    setWillNotDraw(true); // No need to draw until the insets are adjusted

    ViewCompat.setOnApplyWindowInsetsListener(this,
            new android.support.v4ox.view.OnApplyWindowInsetsListener() {
                @Override
                public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                    if (null == mInsets) {
                        mInsets = new Rect();
                    }
                    mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                            insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
                    onInsetsChanged(mInsets);
                    setWillNotDraw(mInsets.isEmpty() || mInsetForeground == null);
                    ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this);
                    return insets.consumeSystemWindowInsets();
                }
            });
}

From source file:com.ruesga.rview.drawer.DrawerScrimInsetsFrameLayout.java

public DrawerScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DrawerScrimInsetsFrameLayout,
            defStyleAttr, R.style.Widget_Drawer_DrawerScrimInsetsFrameLayout);
    mInsetForeground = a.getDrawable(R.styleable.DrawerScrimInsetsFrameLayout_insetForeground);
    a.recycle();//from  w w  w. ja  v  a  2  s .  c  o  m
    setWillNotDraw(true); // No need to draw until the insets are adjusted

    ViewCompat.setOnApplyWindowInsetsListener(this, (v, insets) -> {
        if (null == mInsets) {
            mInsets = new Rect();
        }
        mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
        onInsetsChanged(insets);
        setWillNotDraw(!insets.hasSystemWindowInsets() || mInsetForeground == null);
        ViewCompat.postInvalidateOnAnimation(DrawerScrimInsetsFrameLayout.this);
        return insets.consumeSystemWindowInsets();
    });
}

From source file:com.chen.mail.browse.ConversationPagerController.java

private void setupPageMargin(Context c) {
    final TypedArray a = c.obtainStyledAttributes(new int[] { android.R.attr.listDivider });
    final Drawable divider = a.getDrawable(0);
    a.recycle();/*w w  w  .j a v a 2s .  c om*/
    final int padding = c.getResources().getDimensionPixelOffset(R.dimen.conversation_page_gutter);
    final Drawable gutterDrawable = new PageMarginDrawable(divider, padding, 0, padding, 0,
            c.getResources().getColor(R.color.conversation_view_border_color));
    mPager.setPageMargin(gutterDrawable.getIntrinsicWidth() + 2 * padding);
    mPager.setPageMarginDrawable(gutterDrawable);
}

From source file:android.support.design.internal.ScrimInsetsFrameLayout.java

public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr,
            R.style.Widget_Design_ScrimInsetsFrameLayout);
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground);
    a.recycle();//from  ww  w.  ja va  2 s .  c  o  m
    setWillNotDraw(true); // No need to draw until the insets are adjusted

    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            if (null == mInsets) {
                mInsets = new Rect();
            }
            mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                    insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
            onInsetsChanged(insets);
            setWillNotDraw(!insets.hasSystemWindowInsets() || mInsetForeground == null);
            ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this);
            return insets.consumeSystemWindowInsets();
        }
    });
}

From source file:com.example.busking_test.viewpager.FixedTabsView.java

public FixedTabsView(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
    TypedArray typeArray = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerExtensions);
    mDividerDrawable = typeArray.getDrawable(R.styleable.ViewPagerExtensions_dividerDrawable);
}

From source file:com.ewintory.footballscores.ui.widget.AnimatorStateView.java

private void initialize(Context context, AttributeSet attrs, int defStyle) {
    mRoot = LayoutInflater.from(context).inflate(R.layout.widget_animator_state, this, true);
    ButterKnife.bind(this, mRoot);

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

    String text = a.getString(R.styleable.AnimatorStateView_messageText);
    Drawable image = a.getDrawable(R.styleable.AnimatorStateView_messageImage);

    mTextView.setText(text);/*from  w  ww.j  a v  a  2s.c  o m*/
    mImageView.setImageDrawable(image);

    a.recycle();

    mScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
}

From source file:com.ericyl.utils.ui.widget.translucent.ScrimInsetsFrameLayout.java

public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MineScrimInsetsFrameLayout,
            defStyleAttr, R.style.defaultStyle_ScrimInsetsFrameLayout);
    mInsetForeground = a.getDrawable(R.styleable.MineScrimInsetsFrameLayout_insetForeground);
    a.recycle();//from   w  ww. j a  v  a 2  s .c  om
    setWillNotDraw(true); // No need to draw until the insets are adjusted

    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            if (null == mInsets) {
                mInsets = new Rect();
            }
            mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                    insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
            onInsetsChanged(insets);
            setWillNotDraw(!insets.hasSystemWindowInsets() || mInsetForeground == null);
            ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this);
            return insets.consumeSystemWindowInsets();
        }
    });
}

From source file:com.florianmski.spongeframework.ui.widgets.DrawInsetsFrameLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DrawInsetsFrameLayout, defStyle, 0);
    if (a == null) {
        return;/*from www.  j a  va 2s  .c  o  m*/
    }
    mInsetStatusBarBackground = a.getDrawable(R.styleable.DrawInsetsFrameLayout_insetStatusBarBackground);
    mInsetNavBarBackground = a.getDrawable(R.styleable.DrawInsetsFrameLayout_insetNavBarBackground);
    a.recycle();

    setWillNotDraw(true);
}