List of usage examples for android.content Context obtainStyledAttributes
public final TypedArray obtainStyledAttributes(AttributeSet set, @StyleableRes int[] attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes)
From source file:com.aspsine.swipetoloadlayout.widget.CircleProgressBar.java
private void init(Context context, AttributeSet attrs, int defStyleAttr) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0); // <attr name="mlpb_inner_radius" format="dimension"/> // <attr name="mlpb_background_color" format="color"/> // <attr name="mlpb_progress_color" format="color"/> // <attr name="mlpb_progress_stoke_width" format="dimension"/> // <attr name="mlpb_arrow_width" format="dimension"/> // <attr name="mlpb_arrow_height" format="dimension"/> ///*from w w w .jav a 2s.c om*/ // <attr name="mlpb_progress" format="integer"/> // <attr name="mlpb_max" format="integer"/> // // // <attr name="mlpb_progress_text_size" format="dimension"/> // <attr name="mlpb_progress_text_color" format="color"/> // // <attr name="mlpb_progress_text_offset" format="dimension"/> // // <attr name="mlpb_progress_text_visibility" format="enum"> // <enum name="visible" value="0"/> // <enum name="invisible" value="1"/> // </attr> final float density = getContext().getResources().getDisplayMetrics().density; mBackGroundColor = a.getColor(R.styleable.CircleProgressBar_mlpb_background_color, DEFAULT_CIRCLE_BG_LIGHT); mProgressColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_color, DEFAULT_CIRCLE_BG_LIGHT); mColors = new int[] { mProgressColor }; mInnerRadius = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_inner_radius, -1); mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_stoke_width, (int) (STROKE_WIDTH_LARGE * density)); mArrowWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_width, -1); mArrowHeight = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_height, -1); mTextSize = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_text_size, (int) (DEFAULT_TEXT_SIZE * density)); mTextColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_text_color, Color.BLACK); mShowArrow = a.getBoolean(R.styleable.CircleProgressBar_mlpb_show_arrow, false); mCircleBackgroundEnabled = a.getBoolean(R.styleable.CircleProgressBar_mlpb_enable_circle_background, true); mProgress = a.getInt(R.styleable.CircleProgressBar_mlpb_progress, 0); mMax = a.getInt(R.styleable.CircleProgressBar_mlpb_max, 100); int textVisible = a.getInt(R.styleable.CircleProgressBar_mlpb_progress_text_visibility, 1); if (textVisible != 1) { mIfDrawText = true; } mTextPaint = new Paint(); mTextPaint.setStyle(Paint.Style.FILL); mTextPaint.setColor(mTextColor); mTextPaint.setTextSize(mTextSize); mTextPaint.setAntiAlias(true); a.recycle(); mProgressDrawable = new MaterialProgressDrawable(getContext(), this); super.setImageDrawable(mProgressDrawable); }
From source file:be.ugent.zeus.hydra.ui.SwipeyTabs.java
public SwipeyTabs(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwipeyTabs, defStyle, 0); mBottomBarColor = a.getColor(R.styleable.SwipeyTabs_bottomBarColor, mBottomBarColor); mBottomBarHeight = a.getDimensionPixelSize(R.styleable.SwipeyTabs_bottomBarHeight, 2); mTabIndicatorHeight = a.getDimensionPixelSize(R.styleable.SwipeyTabs_tabIndicatorHeight, 3); mTextColor = a.getColor(R.styleable.SwipeyTabs_tabTextColor, 0xff949494); a.recycle();/* ww w . j a v a2s .c o m*/ init(); }
From source file:cn.com.elex.social_life.support.view.cjj.CircleProgressBar.java
private void init(Context context, AttributeSet attrs, int defStyleAttr) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0); final float density = getContext().getResources().getDisplayMetrics().density; mBackGroundColor = a.getColor(R.styleable.CircleProgressBar_mlpb_background_color, DEFAULT_CIRCLE_BG_LIGHT); mProgressColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_color, DEFAULT_CIRCLE_BG_LIGHT); mColors = new int[] { mProgressColor }; mInnerRadius = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_inner_radius, -1); mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_stoke_width, (int) (STROKE_WIDTH_LARGE * density)); mArrowWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_width, -1); mArrowHeight = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_height, -1); mTextSize = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_text_size, (int) (DEFAULT_TEXT_SIZE * density)); mTextColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_text_color, Color.BLACK); mShowArrow = a.getBoolean(R.styleable.CircleProgressBar_mlpb_show_arrow, false); mCircleBackgroundEnabled = a.getBoolean(R.styleable.CircleProgressBar_mlpb_enable_circle_background, true); mProgress = a.getInt(R.styleable.CircleProgressBar_mlpb_progress, 0); mMax = a.getInt(R.styleable.CircleProgressBar_mlpb_max, 100); int textVisible = a.getInt(R.styleable.CircleProgressBar_mlpb_progress_text_visibility, 1); if (textVisible != 1) { mIfDrawText = true;/*from w w w . j a v a2 s . com*/ } mTextPaint = new Paint(); mTextPaint.setStyle(Paint.Style.FILL); mTextPaint.setColor(mTextColor); mTextPaint.setTextSize(mTextSize); mTextPaint.setAntiAlias(true); a.recycle(); mProgressDrawable = new MaterialProgressDrawable(getContext(), this); super.setImageDrawable(mProgressDrawable); }
From source file:cc.chenghong.vkagetorder.material.CircleProgressBar.java
private void init(Context context, AttributeSet attrs, int defStyleAttr) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0); final float density = getContext().getResources().getDisplayMetrics().density; mBackGroundColor = a.getColor(R.styleable.CircleProgressBar_mlpb_background_color, DEFAULT_CIRCLE_BG_LIGHT); mProgressColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_color, DEFAULT_CIRCLE_BG_LIGHT); mColors = new int[] { mProgressColor }; mInnerRadius = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_inner_radius, -1); mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_stoke_width, (int) (STROKE_WIDTH_LARGE * density)); mArrowWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_width, -1); mArrowHeight = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_height, -1); mTextSize = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_text_size, (int) (DEFAULT_TEXT_SIZE * density)); mTextColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_text_color, Color.BLACK); mShowArrow = a.getBoolean(R.styleable.CircleProgressBar_mlpb_show_arrow, false); mCircleBackgroundEnabled = a.getBoolean(R.styleable.CircleProgressBar_mlpb_enable_circle_background, true); mProgress = a.getInt(R.styleable.CircleProgressBar_mlpb_progress, 0); mMax = a.getInt(R.styleable.CircleProgressBar_mlpb_max, 100); int textVisible = a.getInt(R.styleable.CircleProgressBar_mlpb_progress_text_visibility, 1); if (textVisible != 1) { mIfDrawText = true;//w w w . j a v a 2 s . co m } mTextPaint = new Paint(); mTextPaint.setStyle(Paint.Style.FILL); mTextPaint.setColor(mTextColor); mTextPaint.setTextSize(mTextSize); mTextPaint.setAntiAlias(true); a.recycle(); mProgressDrawable = new MaterialProgressDrawable(getContext(), this); mProgressDrawable.setStartEndTrim(0, (float) 0.75); super.setImageDrawable(mProgressDrawable); }
From source file:com.android.yijiang.kzx.widget.betterpickers.widget.UnderlinePageIndicatorPicker.java
public UnderlinePageIndicatorPicker(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mColorUnderline = getResources().getColor(R.color.dialog_text_color_holo_dark); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BetterPickersDialogFragment, defStyle, 0); mColorUnderline = a.getColor(R.styleable.BetterPickersDialogFragment_bpKeyboardIndicatorColor, mColorUnderline);/*from w w w .j a v a2 s .co m*/ rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:angeloid.dreamnarae.SwipeyTabs.java
public SwipeyTabs(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwipeyTabs, defStyle, 0); mBottomBarColor = a.getColor(R.styleable.SwipeyTabs_bottomBarColor, mBottomBarColor); mBottomBarHeight = a.getDimensionPixelSize(R.styleable.SwipeyTabs_bottomBarHeight, 2); mTabIndicatorHeight = a.getDimensionPixelSize(R.styleable.SwipeyTabs_tabIndicatorHeight, 3); a.recycle();/*w ww . j a v a 2 s . co m*/ init(); }
From source file:com.actionbarsherlock.internal.view.menu.ActionMenuItemView.java
public ActionMenuItemView(Context context, AttributeSet attrs, int defStyle) { //TODO super(context, attrs, defStyle); super(context, attrs); mAllowTextWithIcon = getResources_getBoolean(context, R.bool.abs__config_allowActionMenuItemTextWithIcon); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionMenuItemView, 0, 0); mMinWidth = a.getDimensionPixelSize(R.styleable.SherlockActionMenuItemView_android_minWidth, 0); a.recycle();// w ww . j a v a 2 s . com }
From source file:android.support.v7.internal.view.menu.ActionMenuItemView.java
public ActionMenuItemView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final Resources res = context.getResources(); mAllowTextWithIcon = res.getBoolean(R.bool.abc_config_allowActionMenuItemTextWithIcon); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ActionMenuItemView, defStyle, 0); mMinWidth = a.getDimensionPixelSize(R.styleable.ActionMenuItemView_android_minWidth, 0); a.recycle();/* w w w . ja va2 s .co m*/ final float density = res.getDisplayMetrics().density; mMaxIconSize = (int) (MAX_ICON_SIZE * density + 0.5f); setOnClickListener(this); setOnLongClickListener(this); mSavedPaddingLeft = -1; }
From source file:com.anl.wxb.jieqi.view.VerticalSeekBar.java
private void initialize(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { ViewCompat.setLayoutDirection(this, ViewCompat.LAYOUT_DIRECTION_LTR); if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.VerticalSeekBar, defStyleAttr, defStyleRes);//from w w w .j a v a2 s . c o m final int rotationAngle = a.getInteger(R.styleable.VerticalSeekBar_seekBarRotation, 0); if (isValidRotationAngle(rotationAngle)) { mRotationAngle = rotationAngle; } a.recycle(); } }
From source file:android.support.v7.preference.PreferenceGroup.java
public PreferenceGroup(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mPreferenceList = new ArrayList<>(); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PreferenceGroup, defStyleAttr, defStyleRes);//from w w w .ja v a 2 s . c om mOrderingAsAdded = TypedArrayUtils.getBoolean(a, R.styleable.PreferenceGroup_orderingFromXml, R.styleable.PreferenceGroup_orderingFromXml, true); a.recycle(); }