List of usage examples for android.content.res TypedArray getColor
@ColorInt public int getColor(@StyleableRes int index, @ColorInt int defValue)
From source file:com.ereader.client.ui.view.ScrollingTabsView.java
public ScrollingTabsView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs); this.mContext = context; mDividerMarginTop = (int) (getResources().getDisplayMetrics().density * mDividerMarginTop); mDividerMarginBottom = (int) (getResources().getDisplayMetrics().density * mDividerMarginBottom); mDividerWidth = (int) (getResources().getDisplayMetrics().density * mDividerWidth); 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);// w w w .jav a 2 s . co m mDividerMarginBottom = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_dividerMarginBottom, mDividerMarginBottom); mDividerDrawable = a.getDrawable(R.styleable.ViewPagerExtensions_dividerDrawable); a.recycle(); this.setHorizontalScrollBarEnabled(false); this.setHorizontalFadingEdgeEnabled(false); mContainer = new LinearLayout(context); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); mContainer.setLayoutParams(params); mContainer.setOrientation(LinearLayout.HORIZONTAL); mContainer.setGravity(Gravity.CENTER); this.addView(mContainer); }
From source file:cn.refactor.ultraindicator.lib.UltraIndicatorView.java
private void init(AttributeSet attrs) { TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.UltraIndicatorView); mCheckedColor = ta.getColor(R.styleable.UltraIndicatorView_checkedColor, DEFAULT_CHECKED_COLOR); mUnCheckedColor = ta.getColor(R.styleable.UltraIndicatorView_uncheckedColor, DEFAULT_UNCHECKED_COLOR); mAnimDuration = ta.getInt(R.styleable.UltraIndicatorView_duration, DEFAULT_ANIM_DURATION); ta.recycle();/*from w w w . j a v a2 s.c o m*/ mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setStyle(Paint.Style.FILL); }
From source file:com.chibatching.imgindicatortab.ImgIndicatorTab.java
public ImgIndicatorTab(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) { return;//from www . j a v a 2 s . c o m } // Load default value float defaultTextSize = getResources().getDimension(R.dimen.iit_default_text_size); int defaultSelectedColor = getResources().getColor(R.color.iit_default_selected_text_color); int defaultDeselectedColor = getResources().getColor(R.color.iit_default_deselected_text_color); boolean defaultFitIndicator = getResources().getBoolean(R.bool.iit_default_fit_indicator_with_tab); // Load style attributes TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ImgIndicatorTab, defStyle, 0); setSelectedTextColor(ta.getColor(R.styleable.ImgIndicatorTab_selectedTextColor, defaultSelectedColor)); setDeselectedTextColor( ta.getColor(R.styleable.ImgIndicatorTab_deselectedTextColor, defaultDeselectedColor)); setIndicatorDrawable(ta.getDrawable(R.styleable.ImgIndicatorTab_indicatorDrawable)); setTextSize(ta.getDimension(R.styleable.ImgIndicatorTab_android_textSize, defaultTextSize)); setFitIndicator(ta.getBoolean(R.styleable.ImgIndicatorTab_fitIndicatorWithTabWidth, defaultFitIndicator)); int background = ta.getResourceId(R.styleable.ImgIndicatorTab_android_background, 0); if (background != 0) { setBackgroundResource(background); } ta.recycle(); }
From source file:com.codetroopers.betterpickers.radialtimepicker.RadialSelectorView.java
void setTheme(TypedArray themeColors) { mPaint.setColor(themeColors.getColor(R.styleable.BetterPickersDialogs_bpRadialPointerColor, ContextCompat.getColor(getContext(), R.color.bpBlue))); mSelectionAlpha = themeColors.getInt(R.styleable.BetterPickersDialogs_bpRadialPointerAlpha, 35); }
From source file:com.dean.phonesafe.ui.SlideSwitch.java
public SlideSwitch(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); listener = null;//from ww w.j av a 2s .c o m paint = new Paint(); // paint.setAntiAlias(true); //?Xml? TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.slideswitch); color_theme = a.getColor(R.styleable.slideswitch_themeColor, DEFAULT_COLOR_THEME); isOpen = a.getBoolean(R.styleable.slideswitch_isOpen, false); shape = a.getInt(R.styleable.slideswitch_shape, SHAPE_RECT); a.recycle(); }
From source file:com.ichi2.anki.widgets.DeckAdapter.java
public DeckAdapter(LayoutInflater layoutInflater, Context context) { mLayoutInflater = layoutInflater;// www . j a v a 2s. c o m mDeckList = new ArrayList<>(); // Get the colors from the theme attributes int[] attrs = new int[] { R.attr.zeroCountColor, R.attr.newCountColor, R.attr.learnCountColor, R.attr.reviewCountColor, R.attr.currentDeckBackground, android.R.attr.textColor, R.attr.dynDeckColor, R.attr.expandRef, R.attr.collapseRef }; TypedArray ta = context.obtainStyledAttributes(attrs); Resources res = context.getResources(); mZeroCountColor = ta.getColor(0, res.getColor(R.color.zero_count)); mNewCountColor = ta.getColor(1, res.getColor(R.color.new_count)); mLearnCountColor = ta.getColor(2, res.getColor(R.color.learn_count)); mReviewCountColor = ta.getColor(3, res.getColor(R.color.review_count)); mRowCurrentDrawable = ta.getResourceId(4, 0); mDeckNameDefaultColor = ta.getColor(5, res.getColor(R.color.black)); mDeckNameDynColor = ta.getColor(6, res.getColor(R.color.deckadapter_deck_name_dyn)); mExpandImage = ta.getDrawable(7); mCollapseImage = ta.getDrawable(8); ta.recycle(); }
From source file:com.audionote.widget.SlideSwitch.java
public SlideSwitch(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); listener = null;/*from w w w.j a v a 2 s.c om*/ paint = new Paint(); paint.setAntiAlias(true); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.slideswitch); color_theme = a.getColor(R.styleable.slideswitch_themeColor, DEFAULT_COLOR_THEME); color_back_theme = a.getColor(R.styleable.slideswitch_backColor, Color.WHITE); isOpen = true; shape = SHAPE_CIRCLE; a.recycle(); borderWidth = ScreenUtils.getDipValue(context, 1); border_color = Color.parseColor("#ffcccccc"); }
From source file:cn.picksomething.slidingtabindicator.SlidingTabLayout.java
public SlidingTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.SlidingTabLayout); mTextFocusColor = typedArray.getColor(R.styleable.SlidingTabLayout_textSelectedColor, Color.WHITE); mTextDefaultColor = typedArray.getColor(R.styleable.SlidingTabLayout_textDefaultColor, Color.WHITE); typedArray.recycle();// w w w. java 2 s.co m // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Make sure that the Tab Strips fills this View setFillViewport(true); mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density); mTabStrip = new SlidingTabStrip(context); addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); }
From source file:com.ashlikun.badgeview.BadgeView.java
private void init(AttributeSet attrs) { defaultHeight = dip2px(getContext(), defaultHeight); TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.BadgeView); // set default background setBackground(dip2px(getContext(), radius), a.getColor(R.styleable.BadgeView_bvColor, bvColor)); mHideOnNull = a.getBoolean(R.styleable.BadgeView_bvISHideNull, true); a.recycle();/*from ww w .j a va2 s. c o m*/ setGravity(Gravity.CENTER); setPadding((int) (radius / 3f), 0, (int) (radius / 3f), 0); ViewCompat.setElevation(this, dip2px(getContext(), 1)); setTypeface(null, Typeface.BOLD); }
From source file:com.crazy.toutiaonews.SlidingTabLayout.java
public SlidingTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // ???//from w w w . jav a 2s . c o m TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SlidingTabLayout); int defaultTextColor = a.getColor(R.styleable.SlidingTabLayout_android_textColorPrimary, 0); mDefaultTextColor = a.getColor(R.styleable.SlidingTabLayout_textColorTabDefault, defaultTextColor); mSelectedTextColor = a.getColor(R.styleable.SlidingTabLayout_textColorTabSelected, defaultTextColor); a.recycle(); // =============================== ========= // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Make sure that the Tab Strips fills this View setFillViewport(true); mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density); mTabStrip = new SlidingTabStrip(context); addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); }