List of usage examples for android.content.res TypedArray getDrawable
@Nullable public Drawable getDrawable(@StyleableRes int index)
From source file:com.mark.app.widget.recycler_view.LLMDivider.java
/** * Creates a divider {@link RecyclerView.ItemDecoration} that can be used with a * {@link LinearLayoutManager}./*from ww w.j ava 2s . c o m*/ * * @param context Current context, it will be used to access resources. * @param orientation Divider orientation. Should be {@link #HORIZONTAL_LIST} or {@link #VERTICAL_LIST}. */ public LLMDivider(Context context, int orientation) { final TypedArray a = context.obtainStyledAttributes(ATTRS); mDivider = a.getDrawable(0); a.recycle(); setOrientation(orientation); }
From source file:cn.tan.lib.widget.DrawShadowFrameLayout.java
public DrawShadowFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DrawShadowFrameLayout, 0, 0); mShadowDrawable = a.getDrawable(R.styleable.DrawShadowFrameLayout_shadowDrawable); if (mShadowDrawable != null) { mShadowDrawable.setCallback(this); if (mShadowDrawable instanceof NinePatchDrawable) { mShadowNinePatchDrawable = (NinePatchDrawable) mShadowDrawable; }//from w w w . j av a 2s .co m } mShadowVisible = a.getBoolean(R.styleable.DrawShadowFrameLayout_shadowVisible, true); setWillNotDraw(!mShadowVisible || mShadowDrawable == null); a.recycle(); }
From source file:com.saarang.samples.apps.iosched.ui.widget.MultiSwipeRefreshLayout.java
public MultiSwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); final TypedArray a = context.obtainStyledAttributes(attrs, com.saarang.samples.apps.iosched.R.styleable.MultiSwipeRefreshLayout, 0, 0); mForegroundDrawable = a .getDrawable(com.saarang.samples.apps.iosched.R.styleable.MultiSwipeRefreshLayout_foreground); if (mForegroundDrawable != null) { mForegroundDrawable.setCallback(this); setWillNotDraw(false);/*from www . j a va 2s. co m*/ } a.recycle(); }
From source file:com.laynemobile.android.widget.AndroidDrawer.java
private void init(Context context, AttributeSet attrs, int defStyleAttr) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NavigationView, defStyleAttr, R.style.Widget_Design_NavigationView); Util.setViewBackground(this, a.getDrawable(R.styleable.NavigationView_android_background)); if (a.hasValue(R.styleable.NavigationView_elevation)) { ViewCompat.setElevation(this, (float) a.getDimensionPixelSize(R.styleable.NavigationView_elevation, 0)); }//from ww w.ja va 2 s.c o m ViewCompat.setFitsSystemWindows(this, a.getBoolean(R.styleable.NavigationView_android_fitsSystemWindows, false)); this.maxWidth = a.getDimensionPixelSize(R.styleable.NavigationView_android_maxWidth, 0); this.widthMargin = Util.getActionBarSize(context); a.recycle(); }
From source file:com.mycheez.adapter.DividerItemDecoration.java
public DividerItemDecoration(Context context, AttributeSet attrs) { final TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.listDivider }); mDivider = a.getDrawable(0); a.recycle();//from w ww . j ava 2s . co m }
From source file:com.merlin.view.recycler.RecyclerListDecoration.java
public RecyclerListDecoration(Context context, int orientation, int height, int offsetStart, int offsetEnd, int color) { this.mOrientation = orientation; this.mHeight = height; this.mOffsetStart = offsetStart; this.mOffsetEnd = offsetEnd; this.mColor = color; if (mColor != 0) { dividerPaint = new Paint(); dividerPaint.setColor(mColor);// w w w.j a va 2 s. c om } else { final TypedArray typed = context.obtainStyledAttributes(new int[] { android.R.attr.listDivider }); mDivider = typed.getDrawable(0); typed.recycle(); } }
From source file:com.jakewharton.u2020.ui.misc.ScrimInsetsFrameLayout.java
private void init(Context context, AttributeSet attrs, int defStyle) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0); if (a == null) { return;/*from ww w . jav a2s.c o m*/ } insetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForeground); a.recycle(); setWillNotDraw(true); }
From source file:com.abdlh.axelspringerhack.UI.Views.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) { mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForegroundBild); a.recycle();//ww w .j a v a 2 s. c om } setWillNotDraw(true); }
From source file:com.marshalchen.ultimaterecyclerview.ui.timelineview.TimelineView.java
private void init(AttributeSet attrs) { TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.timeline_style); mMarker = typedArray.getDrawable(R.styleable.timeline_style_tls_marker); mStartLine = typedArray.getDrawable(R.styleable.timeline_style_tls_line); mEndLine = typedArray.getDrawable(R.styleable.timeline_style_tls_line); mMarkerSize = typedArray.getDimensionPixelSize(R.styleable.timeline_style_tls_marker_size, 25); mLineSize = typedArray.getDimensionPixelSize(R.styleable.timeline_style_tls_line_size, 2); typedArray.recycle();/*from w ww .j av a2 s .c o m*/ if (mMarker == null) { mMarker = ContextCompat.getDrawable(mContext, R.drawable.timelinedefaultmarker); } }
From source file:co.codecrunch.musicplayerlite.uicomponent.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 ww w . jav a 2 s . c o m*/ } mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForeground_ui); a.recycle(); setWillNotDraw(true); }