List of usage examples for android.content.res TypedArray getDrawable
@Nullable public Drawable getDrawable(@StyleableRes int index)
From source file:com.actionbarsherlock.internal.view.menu.ListMenuItemView.java
public ListMenuItemView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs); mContext = context;/*from w w w .ja v a 2 s . c om*/ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockMenuView, defStyle, 0); mBackground = a.getDrawable(R.styleable.SherlockMenuView_itemBackground); mTextAppearance = a.getResourceId(R.styleable.SherlockMenuView_itemTextAppearance, -1); mPreserveIconSpacing = a.getBoolean(R.styleable.SherlockMenuView_preserveIconSpacing, false); mTextAppearanceContext = context; a.recycle(); }
From source file:android.support.v7.widget.ActionBarContainer.java
public ActionBarContainer(Context context, AttributeSet attrs) { super(context, attrs); // Set a transparent background so that we project appropriately. final Drawable bg = Build.VERSION.SDK_INT >= 21 ? new ActionBarBackgroundDrawableV21(this) : new ActionBarBackgroundDrawable(this); ViewCompat.setBackground(this, bg); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ActionBar); mBackground = a.getDrawable(R.styleable.ActionBar_background); mStackedBackground = a.getDrawable(R.styleable.ActionBar_backgroundStacked); mHeight = a.getDimensionPixelSize(R.styleable.ActionBar_height, -1); if (getId() == R.id.split_action_bar) { mIsSplit = true;//from w w w . j a va 2 s .co m mSplitBackground = a.getDrawable(R.styleable.ActionBar_backgroundSplit); } a.recycle(); setWillNotDraw(mIsSplit ? mSplitBackground == null : mBackground == null && mStackedBackground == null); }
From source file:com.actionbarsherlock.internal.widget.IcsLinearLayout.java
public IcsLinearLayout(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, /*com.android.internal.R.styleable.*/LinearLayout); setDividerDrawable(a.getDrawable(/*com.android.internal.R.styleable.*/LinearLayout_divider)); mShowDividers = a.getInt(/*com.android.internal.R.styleable.*/LinearLayout_showDividers, SHOW_DIVIDER_NONE); mDividerPadding = a.getDimensionPixelSize(/*com.android.internal.R.styleable.*/LinearLayout_dividerPadding, 0);// ww w . j a v a 2 s . c om a.recycle(); }
From source file:com.maxleap.mall.widget.FlexibleDividerDecoration.java
protected FlexibleDividerDecoration(Builder builder) { if (builder.mPaintProvider != null) { mDividerType = DividerType.PAINT; mPaintProvider = builder.mPaintProvider; } else if (builder.mColorProvider != null) { mDividerType = DividerType.COLOR; mColorProvider = builder.mColorProvider; mPaint = new Paint(); setSizeProvider(builder);/*from w w w . ja va 2s . com*/ } else { mDividerType = DividerType.DRAWABLE; if (builder.mDrawableProvider == null) { TypedArray a = builder.mContext.obtainStyledAttributes(ATTRS); final Drawable divider = a.getDrawable(0); a.recycle(); mDrawableProvider = new DrawableProvider() { @Override public Drawable drawableProvider(int position, RecyclerView parent) { return divider; } }; } else { mDrawableProvider = builder.mDrawableProvider; } mSizeProvider = builder.mSizeProvider; } mVisibilityProvider = builder.mVisibilityProvider; mShowLastDivider = builder.mShowLastDivider; }
From source file:com.sckftr.android.app.view.InsetFrameLayout.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 w ww .j a v a2 s . c o m*/ mDefaultInsetBackground = mInsetBackground = a .getDrawable(R.styleable.DrawInsetsFrameLayout_insetBackground); a.recycle(); setWillNotDraw(true); }
From source file:com.thejoshwa.ultrasonic.androidapp.util.Util.java
public static Drawable getDrawableFromAttribute(Context context, int attr) { int[] attrs = new int[] { attr }; android.content.res.TypedArray ta = context.obtainStyledAttributes(attrs); Drawable drawableFromTheme = ta.getDrawable(0); ta.recycle();/* ww w.ja v a 2 s . c o m*/ return drawableFromTheme; }
From source file:com.android.cards.view.helper.CardViewHelperImplBase.java
@Override public Drawable getResourceFromAttrs(Context themedContext, int attr) { // Create an array of the attributes we want to resolve // using values from a theme int[] attrs = new int[] { attr /* index 0 */ }; // Obtain the styled attributes. 'themedContext' is a context with a // theme, typically the current Activity (i.e. 'this') TypedArray ta = themedContext.obtainStyledAttributes(attrs); // To get the value of the 'listItemBackground' attribute that was // set in the theme used in 'themedContext'. The parameter is the index // of the attribute in the 'attrs' array. The returned Drawable // is what you are after Drawable drawableFromTheme = ta.getDrawable(0 /* index */); // Finally, free the resources used by TypedArray ta.recycle();//from w ww . ja v a 2 s. c o m return drawableFromTheme; }
From source file:com.rolmex.android.nemalltone.fragment.ViewPageFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { context = getActivity();/*from w w w . jav a 2s . com*/ View mView = inflater.inflate(R.layout.view_main, null); // int[] attrs = { android.R.attr.windowBackground }; TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.windowBackground, outValue, true); TypedArray style = context.getTheme().obtainStyledAttributes(outValue.resourceId, attrs); windowBackground = style.getDrawable(0); style.recycle(); // head_layout = (RelativeLayout)mView.findViewById(R.id.head_layout); // head_layout.setBackground(windowBackground); // ?? table_layout = (LinearLayout) mView.findViewById(R.id.table_layout); // table_layout.setBackground(windowBackground); // table_layout.setBackgroundResource(context.getResources().getColor(R.color.white)); DisplayMetrics dm = new DisplayMetrics(); ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm); // ??veiwPager?2 width = dm.widthPixels / 2 - 1; hsv = (HorizontalScrollView) mView.findViewById(R.id.main_ho_sv); hfl = (FrameLayout) mView.findViewById(R.id.main_fl); TextView placeView = new TextView(context); placeView.setLayoutParams(new FrameLayout.LayoutParams(width * 2, 10)); placeView.setBackgroundResource(R.color.half_white); hfl.addView(placeView); slidView = new TextView(context); slidView.setLayoutParams(new FrameLayout.LayoutParams(width, 10)); slidView.setBackgroundResource(R.color.holo_blue); hfl.addView(slidView); home_view = (TextView) mView.findViewById(R.id.home_mian_view); always_view = (TextView) mView.findViewById(R.id.home_always_view); showLeft = (Button) mView.findViewById(R.id.showLeft); showRight = (Button) mView.findViewById(R.id.showRight); mPager = (JazzyViewPager) mView.findViewById(R.id.pager); /** * ? */ mPager.setTransitionEffect(TransitionEffect.FlipHorizontal); PageFragment1 page1 = new PageFragment1(); PageFragment2 page2 = new PageFragment2(); pagerItemList.add(page1); pagerItemList.add(page2); mAdapter = new MyAdapter(getFragmentManager()); mPager.setAdapter(mAdapter); mPager.setPageMargin(30); mPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { updateTableBg(position); slidView.setTranslationX(width * position); if (myPageChangeListener != null) myPageChangeListener.onPageSelected(position); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { if (arg1 > 0.0) slidView.setTranslationX(width * arg1); } @Override public void onPageScrollStateChanged(int position) { } }); return mView; }
From source file:com.github.andrewlord1990.materialandroid.component.list.ListItemView.java
private void loadIcon(TypedArray typedAttrs) { Drawable icon = typedAttrs.getDrawable(R.styleable.MDListItemView_md_list_icon); setIcon(icon); }
From source file:com.alex.view.loop.IndicatorView.java
public IndicatorView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // ?// ww w. j av a 2 s . co m TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.IndicatorView); normalBp = drawableToBitamp(ta.getDrawable(R.styleable.IndicatorView_normalDrawable)); selectBp = drawableToBitamp(ta.getDrawable(R.styleable.IndicatorView_selectDrawable)); mInterval = ta.getDimensionPixelOffset(R.styleable.IndicatorView_indicatorInterval, 6); normalColor = ta.getColor(R.styleable.IndicatorView_normalColor, Color.GRAY); selectColor = ta.getColor(R.styleable.IndicatorView_selectColor, Color.RED); mRadius = ta.getInteger(R.styleable.IndicatorView_indicatorRadius, 6); isCirculate = ta.getBoolean(R.styleable.IndicatorView_isCirculate, true); ta.recycle(); // ? init(); }