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:de.vanita5.twittnuker.util.ThemeUtils.java

@Deprecated
public static Drawable getActionBarSplitBackground(final Context context, final boolean applyAlpha) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.backgroundSplit },
            android.R.attr.actionBarStyle, 0);
    final Drawable d = a.getDrawable(0);
    a.recycle();/* ww w.  j ava  2 s . co m*/
    return applyActionBarDrawable(context, d, applyAlpha);
}

From source file:com.e.library.widget.decorator.EDividerDecoration.java

public void setDivider(int[] attrs) {
    final TypedArray a = mContext.obtainStyledAttributes(attrs);
    mDivider = a.getDrawable(0);
    a.recycle();/*www.  jav a 2 s.co m*/
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static Drawable getActionBarBackground(final Context context, final int themeRes) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.background },
            android.R.attr.actionBarStyle, themeRes);
    final Drawable d = a.getDrawable(0);
    a.recycle();// w  w w . j a  v  a2s .  c om
    return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

@Deprecated
public static Drawable getActionBarStackedBackground(final Context context, final boolean applyAlpha) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.backgroundStacked },
            android.R.attr.actionBarStyle, 0);
    final Drawable d = a.getDrawable(0);
    a.recycle();/*from   ww w.  j a  va  2  s . co m*/
    return applyActionBarDrawable(context, d, applyAlpha);
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static Drawable getActionBarBackground(final Context context, final int themeRes,
        final int accentColor) {
    if (!isDarkTheme(themeRes)) {
        final ColorDrawable d = new ActionBarColorDrawable(accentColor);
        return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
    }// w w  w.ja v  a  2 s.c  om
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.background },
            android.R.attr.actionBarStyle, themeRes);
    final Drawable d = a.getDrawable(0);
    a.recycle();
    return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static Drawable getActionBarSplitBackground(final Context context, final int themeRes) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.backgroundSplit },
            android.R.attr.actionBarStyle, themeRes);
    final Drawable d = a.getDrawable(0);
    a.recycle();//from  w w w.  ja  v  a  2s  .co  m
    return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static Drawable getActionBarStackedBackground(final Context context, final int themeRes) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.backgroundStacked },
            android.R.attr.actionBarStyle, themeRes);
    final Drawable d = a.getDrawable(0);
    a.recycle();/*from w  ww  . j  a  va 2 s  .  com*/
    return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
}

From source file:com.abewy.android.apps.contacts.widget.BezelImageView.java

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

    // Attribute initialization
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BezelImageView, defStyle, 0);

    setBorderDrawable(a.getDrawable(R.styleable.BezelImageView_borderDrawable));

    a.recycle();/*w w  w.jav  a2 s  . c  o m*/
}

From source file:com.camnter.easyrecyclerview.widget.decorator.EasyDividerItemDecoration.java

/**
 * set default divider color//  ww w . ja v  a2 s . c o  m
 *
 * @param context context
 */
private void setDefaultDivider(Context context) {
    final TypedArray typedArray = context.obtainStyledAttributes(ATTRS);
    this.mDivider = typedArray.getDrawable(0);
    typedArray.recycle();
}

From source file:com.ceabie.EffectiveLib.EffectImageView.java

private void initView(AttributeSet attrs) {
    if (attrs != null) {
        TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.EffectImageView);
        mEffectDrawable = array.getDrawable(R.styleable.EffectImageView_EffectMark);
        array.recycle();//from www .  j  a  v a  2s  .c  o m
    }

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    mHardware = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            && (ViewCompat.getLayerType(this) != ViewCompat.LAYER_TYPE_SOFTWARE);
    if (mHardware) {
        // ?
        ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_HARDWARE, mPaint);
    }
}