public CustomGauge(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomGauge, 0, 0); // stroke style mStrokeWidth = a.getDimension(R.styleable.CustomGauge_strokeWidth, 10); mStrokeColor = a.getColor(R.styleable.CustomGauge_strokeColor, android.R.color.darker_gray); mStrokeCap = a.getString(R.styleable.CustomGauge_strokeCap); // angel start and sweep (opposite direction 0, 270, 180, 90) mStartAngel = a.getInt(R.styleable.CustomGauge_startAngel, 0); mSweepAngel = a.getInt(R.styleable.CustomGauge_sweepAngel, 360); // scale (from mStartValue to mEndValue) mStartValue = a.getInt(R.styleable.CustomGauge_startValue, 0); mEndValue = a.getInt(R.styleable.CustomGauge_endValue, 1000); // pointer size and color mPointSize = a.getColor(R.styleable.CustomGauge_pointSize, 0); mPointStartColor = a.getColor(R.styleable.CustomGauge_pointStartColor, android.R.color.white); mPointEndColor = a.getColor(R.styleable.CustomGauge_pointEndColor, android.R.color.white); // calculating one point sweep mPointAngel = ((double) Math.abs(mSweepAngel) / (mEndValue - mStartValue)); a.recycle(); init(); }
public WeightProgressBar(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); this.a = null; this.b = 0.0f; this.c = 0; this.d = 0; this.e = 0; this.f = 0; this.g = 150.0f; this.h = 0.0f; this.i = 0.0f; TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, t.WeightProgressBar); this.b = obtainStyledAttributes.getDimension(0, BitmapDescriptorFactory.HUE_ORANGE); this.c = obtainStyledAttributes.getColor(1, -1); this.e = obtainStyledAttributes.getColor(3, -10919831); this.d = obtainStyledAttributes.getColor(2, -12827569); this.f = obtainStyledAttributes.getColor(4, -8476672); this.g = (float) obtainStyledAttributes.getInteger(5, a.ap); this.h = obtainStyledAttributes.getFloat(6, 0.0f); this.i = obtainStyledAttributes.getFloat(6, 0.0f); obtainStyledAttributes.recycle(); this.a = new Paint(); this.a.setColor(this.e); this.a.setStyle(Style.STROKE); this.a.setStrokeWidth(this.b); this.a.setAntiAlias(true); }
/** * Parse the attributes passed to the view from the XML * * @param a the attributes to parse */ private void parseAttributes(TypedArray a) { barWidth = (int) a.getDimension(R.styleable.ProgressWheel_pwBarWidth, barWidth); rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_pwRimWidth, rimWidth); spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_pwSpinSpeed, spinSpeed); barLength = (int) a.getDimension(R.styleable.ProgressWheel_pwBarLength, barLength); delayMillis = a.getInteger(R.styleable.ProgressWheel_pwDelayMillis, delayMillis); if (delayMillis < 0) { delayMillis = 10; } // Only set the text if it is explicitly defined if (a.hasValue(R.styleable.ProgressWheel_pwText)) { setText(a.getString(R.styleable.ProgressWheel_pwText)); } barColor = a.getColor(R.styleable.ProgressWheel_pwBarColor, barColor); textColor = a.getColor(R.styleable.ProgressWheel_pwTextColor, textColor); rimColor = a.getColor(R.styleable.ProgressWheel_pwRimColor, rimColor); circleColor = a.getColor(R.styleable.ProgressWheel_pwCircleColor, circleColor); contourColor = a.getColor(R.styleable.ProgressWheel_pwContourColor, contourColor); textSize = (int) a.getDimension(R.styleable.ProgressWheel_pwTextSize, textSize); contourSize = a.getDimension(R.styleable.ProgressWheel_pwContourSize, contourSize); a.recycle(); }
/** * Parse the attributes passed to the view from the XML * * @param a the attributes to parse */ private void parseAttributes(TypedArray a) { barWidth = (int) a.getDimension(R.styleable.ProgressWheel_barWidth, barWidth); rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_rimWidth, rimWidth); spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_spinSpeed, spinSpeed); delayMillis = (int) a.getInteger(R.styleable.ProgressWheel_delayMillis, delayMillis); if (delayMillis < 0) { delayMillis = 0; } barColor = a.getColor(R.styleable.ProgressWheel_barColor, barColor); barLength = (int) a.getDimension(R.styleable.ProgressWheel_barLength, barLength); textSize = (int) a.getDimension(R.styleable.ProgressWheel_textSize, textSize); textColor = (int) a.getColor(R.styleable.ProgressWheel_textColor, textColor); setText(a.getString(R.styleable.ProgressWheel_text)); rimColor = (int) a.getColor(R.styleable.ProgressWheel_rimColor, rimColor); circleColor = (int) a.getColor(R.styleable.ProgressWheel_circleColor, circleColor); }
private void init(Context context, AttributeSet attrs) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CircleTextView); mText = typedArray.getString(R.styleable.CircleTextView_Text); mTextColor = typedArray.getColor(R.styleable.CircleTextView_TextColor, Color.WHITE); mCircleColor = typedArray.getColor(R.styleable.CircleTextView_CircleColor, Color.BLACK); mTextSize = typedArray.getDimension(R.styleable.CircleTextView_TextSize, 30); boolean isRandomColor = typedArray.getBoolean(R.styleable.CircleTextView_RandomColor, true); typedArray.recycle(); mCirclePaint = new Paint(); mCirclePaint.setAntiAlias(true); if (isRandomColor) mCirclePaint.setColor(getRandomColor()); else mCirclePaint.setColor(mCircleColor); mTextPaint = new Paint(); mTextPaint.setAntiAlias(true); mTextPaint.setColor(mTextColor); mTextPaint.setTextSize(mTextSize); mTextPaint.setTextAlign(Paint.Align.CENTER); Paint.FontMetrics fm = mTextPaint.getFontMetrics(); offY = (fm.bottom - fm.top) / 2 - fm.bottom; if (mText == null || mText.length() == 0) mText = "无"; if (mText.length() > 1) mText = mText.substring(0, 1); }
public CropImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mFocusWidth = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, mFocusWidth, getResources().getDisplayMetrics()); mFocusHeight = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, mFocusHeight, getResources().getDisplayMetrics()); mBorderWidth = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, mBorderWidth, getResources().getDisplayMetrics()); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CropImageView); mMaskColor = a.getColor(R.styleable.CropImageView_cropMaskColor, mMaskColor); mBorderColor = a.getColor(R.styleable.CropImageView_cropBorderColor, mBorderColor); mBorderWidth = a.getDimensionPixelSize(R.styleable.CropImageView_cropBorderWidth, mBorderWidth); mFocusWidth = a.getDimensionPixelSize(R.styleable.CropImageView_cropFocusWidth, mFocusWidth); mFocusHeight = a.getDimensionPixelSize(R.styleable.CropImageView_cropFocusHeight, mFocusHeight); mDefaultStyleIndex = a.getInteger(R.styleable.CropImageView_cropStyle, mDefaultStyleIndex); mStyle = styles[mDefaultStyleIndex]; a.recycle(); // 只允许图片为当前的缩放模式 setScaleType(ScaleType.MATRIX); }
private void updateStyle(TypedArray styled, boolean invalidate) { int backgroundColor = styled.getColor(R.styleable.ShowcaseView_sv_backgroundColor, Color.argb(128, 80, 80, 80)); int showcaseColor = styled.getColor(R.styleable.ShowcaseView_sv_showcaseColor, HOLO_BLUE); String buttonText = styled.getString(R.styleable.ShowcaseView_sv_buttonText); if (TextUtils.isEmpty(buttonText)) { buttonText = getResources().getString(android.R.string.ok); } boolean tintButton = styled.getBoolean(R.styleable.ShowcaseView_sv_tintButtonColor, true); int titleTextAppearance = styled.getResourceId( R.styleable.ShowcaseView_sv_titleTextAppearance, R.style.TextAppearance_ShowcaseView_Title); int detailTextAppearance = styled.getResourceId( R.styleable.ShowcaseView_sv_detailTextAppearance, R.style.TextAppearance_ShowcaseView_Detail); styled.recycle(); showcaseDrawer.setShowcaseColour(showcaseColor); showcaseDrawer.setBackgroundColour(backgroundColor); tintButton(showcaseColor, tintButton); mEndButton.setText(buttonText); textDrawer.setTitleStyling(titleTextAppearance); textDrawer.setDetailStyling(detailTextAppearance); hasAlteredText = true; if (invalidate) { invalidate(); } }
public RoundProgressBar(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); paint = new Paint(); TypedArray mTypedArray = context.obtainStyledAttributes(attrs, R.styleable.RoundProgressBar); // 获取自定义属性和默认值,第一个参数是从用户属性中得到的设置,如果用户没有设置,那么就用默认的属性,即:第二个参数 // 圆环的颜色 ringColor = mTypedArray.getColor(R.styleable.RoundProgressBar_ringColor, 0xff50c0e9); // 圆环进度条的颜色 ringProgressColor = mTypedArray.getColor(R.styleable.RoundProgressBar_ringProgressColor, 0xffffc641); // 文字的颜色 textColor = mTypedArray.getColor(R.styleable.RoundProgressBar_textColor, 0xffff5f5f); // 文字的大小 textSize = mTypedArray.getDimension(R.styleable.RoundProgressBar_textSize, 25); // 圆环的宽度 ringWidth = mTypedArray.getDimension(R.styleable.RoundProgressBar_ringWidth, 10); // 最大进度 max = mTypedArray.getInteger(R.styleable.RoundProgressBar_max, 100); // 当前进度 progress = mTypedArray.getInt(R.styleable.RoundProgressBar_progress, 30); // 是否显示中间的进度 textIsDisplayable = mTypedArray.getBoolean(R.styleable.RoundProgressBar_textIsDisplayable, true); // 进度的风格,实心或者空心 style = mTypedArray.getInt(R.styleable.RoundProgressBar_style, 0); // 进度开始的角度数 startAngle = mTypedArray.getInt(R.styleable.RoundProgressBar_startAngle, -90); // 圆心的颜色 centreColor = mTypedArray.getColor(R.styleable.RoundProgressBar_centreColor, 0); // 回收资源 mTypedArray.recycle(); }
private void initAttrs(Context context, AttributeSet attrs) { TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.DownloadProgressView, 0, 0); try { mRadius = array.getDimension(R.styleable.DownloadProgressView_circleRadius, 0); mStrokeWidth = array.getDimension(R.styleable.DownloadProgressView_strokeWidth, 0); mLineWidth = array.getDimension(R.styleable.DownloadProgressView_lineWidth, 0); mProgressDuration = array.getInteger( R.styleable.DownloadProgressView_progressDuration, DEFAULT_PROGRESS_DURATION); mResultDuration = array.getInteger( R.styleable.DownloadProgressView_resultDuration, DEFAULT_RESULT_DURATION); mProgressBackgroundColor = array.getColor(R.styleable.DownloadProgressView_progressBackgroundColor, 0); mDrawingColor = array.getColor(R.styleable.DownloadProgressView_drawingColor, 0); mProgressColor = array.getColor(R.styleable.DownloadProgressView_progressColor, 0); mCircleBackgroundColor = array.getColor(R.styleable.DownloadProgressView_circleBackgroundColor, 0); mOvershootValue = array.getFloat(R.styleable.DownloadProgressView_overshootValue, DEFAULT_OVERSHOOT_VALUE); } finally { array.recycle(); } }
public void setup(AttributeSet attrs) { paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStyle(Style.FILL); paint.setStrokeCap(Cap.ROUND); springSystem = SpringSystem.create(); spring = springSystem.createSpring(); spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50, 7)); this.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { toggle(defaultAnimate); } }); TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ToggleButton); offBorderColor = typedArray.getColor(R.styleable.ToggleButton_offBorderColor, offBorderColor); onColor = typedArray.getColor(R.styleable.ToggleButton_onColor, onColor); spotColor = typedArray.getColor(R.styleable.ToggleButton_spotColor, spotColor); offColor = typedArray.getColor(R.styleable.ToggleButton_offColor, offColor); borderWidth = typedArray.getDimensionPixelSize(R.styleable.ToggleButton_borderWidth, borderWidth); defaultAnimate = typedArray.getBoolean(R.styleable.ToggleButton_animate, defaultAnimate); typedArray.recycle(); borderColor = offBorderColor; }
/** * Apply base class attrs. * * @param attrs */ private void processBaseAttrs(TypedArray attrs) { // renderMode RenderMode renderMode = RenderMode.values()[attrs.getInt(R.styleable.Plot_renderMode, getRenderMode().ordinal())]; if (renderMode != getRenderMode()) { setRenderMode(renderMode); } // title setTitle(attrs.getString(R.styleable.Plot_label)); getTitleWidget() .getLabelPaint() .setTextSize( attrs.getDimension( R.styleable.Plot_labelTextSize, PixelUtils.spToPix(DEFAULT_TITLE_WIDGET_TEXT_SIZE_SP))); getTitleWidget() .getLabelPaint() .setColor( attrs.getColor( R.styleable.Plot_labelTextColor, getTitleWidget().getLabelPaint().getColor())); getBackgroundPaint() .setColor( attrs.getColor(R.styleable.Plot_backgroundColor, getBackgroundPaint().getColor())); AttrUtils.configureLinePaint( attrs, getBorderPaint(), R.styleable.Plot_borderColor, R.styleable.Plot_borderThickness); }
public ColorTrackView(Context context, AttributeSet attrs) { super(context, attrs); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ColorTrackView); mText = ta.getString(R.styleable.ColorTrackView_text); mTextNormalSize = ta.getDimensionPixelSize(R.styleable.ColorTrackView_text_normal_size, mTextNormalSize); mTextSelectSize = ta.getDimensionPixelSize(R.styleable.ColorTrackView_text_select_size, mTextNormalSize); mTextOriginColor = ta.getColor(R.styleable.ColorTrackView_text_origin_color, mTextOriginColor); mTextChangeColor = ta.getColor(R.styleable.ColorTrackView_text_change_color, mTextChangeColor); mProgress = ta.getFloat(R.styleable.ColorTrackView_progress, 0); mDirection = ta.getInt(R.styleable.ColorTrackView_direction, mDirection); bSelected = ta.getBoolean(R.styleable.ColorTrackView_isSelect, bSelected); ta.recycle(); mPaint.setTextSize(mTextNormalSize); measureText(); mTextOriginColorR = (mTextChangeColor & 0xff0000) >> 16; mTextOriginColorG = (mTextChangeColor & 0x00ff00) >> 8; mTextOriginColorB = (mTextChangeColor & 0x0000ff); }
private void init(Context context, AttributeSet attrs, int defStyle) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ToggleImageButton, defStyle, 0); boolean checked = a.getBoolean(R.styleable.ToggleImageButton_android_checked, false); setChecked(checked); mSrcDrawable = a.getDrawable(R.styleable.ToggleImageButton_android_src); mTintColor = a.getColor(R.styleable.ToggleImageButton_android_tint, 0); mCheckedDrawable = a.getDrawable(R.styleable.ToggleImageButton_checkedSrc); mCheckedTintColor = a.getColor(R.styleable.ToggleImageButton_checkedTint, 0); mBlurRadius = a.getFloat(R.styleable.ToggleImageButton_checkedBlurRadius, 0); a.recycle(); super.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { setChecked(!isChecked(), true); } }); if (mBlurRadius != 0.0f) { Drawable drawable = resolveCheckedDrawable(); if (BuildConfig.DEBUG) Log.d(LOG_TAG, "Checked drawable is a " + drawable.toString()); if (drawable instanceof BitmapDrawable) { BitmapDrawable bd = (BitmapDrawable) drawable; Paint paint = new Paint(); paint.setMaskFilter(new BlurMaskFilter(mBlurRadius, BlurMaskFilter.Blur.SOLID)); Bitmap bitmap = bd.getBitmap().extractAlpha(paint, null); mCheckedDrawable = new BitmapDrawable(getContext().getResources(), bitmap); } } }
void initialize() { final LayoutParams frame = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); setLayoutParams(frame); final Resources res = getContext().getResources(); mViewSize = res.getDimensionPixelOffset(R.dimen.datepicker_view_animator_height); mChildSize = res.getDimensionPixelOffset(R.dimen.datepicker_year_label_height); setVerticalFadingEdgeEnabled(true); setFadingEdgeLength(mChildSize / 3); final int paddingTop = res.getDimensionPixelSize(R.dimen.datepicker_year_picker_padding_top); setPadding(0, paddingTop, 0, 0); setOnItemClickListener(this); setDividerHeight(0); TypedArray typedArray = getContext().obtainStyledAttributes(R.styleable.YearPickerView); try { mYearSelectedCircleColor = typedArray.getColor( R.styleable.YearPickerView_yearListSelectorColor, SUtils.COLOR_CONTROL_ACTIVATED); setBackgroundColor( typedArray.getColor(R.styleable.YearPickerView_yearPickerBgColor, Color.TRANSPARENT)); } finally { typedArray.recycle(); } mAdapter = new YearAdapter(getContext(), R.layout.year_label_text_view); setAdapter(mAdapter); }
protected void initByAttributes(TypedArray attributes) { finishedStrokeColor = attributes.getColor(R.styleable.ArcProgress_arc_finished_color, default_finished_color); unfinishedStrokeColor = attributes.getColor(R.styleable.ArcProgress_arc_unfinished_color, default_unfinished_color); textColor = attributes.getColor(R.styleable.ArcProgress_arc_text_color, default_text_color); textSize = attributes.getDimension(R.styleable.ArcProgress_arc_text_size, default_text_size); arcAngle = attributes.getFloat(R.styleable.ArcProgress_arc_angle, default_arc_angle); setMax(attributes.getInt(R.styleable.ArcProgress_arc_max, default_max)); setProgress(attributes.getInt(R.styleable.ArcProgress_arc_progress, 0)); strokeWidth = attributes.getDimension(R.styleable.ArcProgress_arc_stroke_width, default_stroke_width); suffixTextSize = attributes.getDimension( R.styleable.ArcProgress_arc_suffix_text_size, default_suffix_text_size); suffixText = TextUtils.isEmpty(attributes.getString(R.styleable.ArcProgress_arc_suffix_text)) ? default_suffix_text : attributes.getString(R.styleable.ArcProgress_arc_suffix_text); suffixTextPadding = attributes.getDimension( R.styleable.ArcProgress_arc_suffix_text_padding, default_suffix_padding); bottomTextSize = attributes.getDimension( R.styleable.ArcProgress_arc_bottom_text_size, default_bottom_text_size); bottomText = attributes.getString(R.styleable.ArcProgress_arc_bottom_text); }
private void loadTheme() { /* Default values */ buttonNextIcon = getResources().getDrawable(R.drawable.ic_arrow_forward); buttonFinishIcon = getResources().getDrawable(R.drawable.ic_done); /* Custom values */ int[] attrs = { R.attr.colorPrimary, R.attr.colorPrimaryDark, android.R.attr.textColorPrimary, android.R.attr.textColorSecondary, R.attr.sifNextIcon, R.attr.sifFinishIcon }; TypedArray array = obtainStyledAttributes(attrs); textFieldBackgroundColor = array.getColor(0, 0); progressBackgroundColor = array.getColor(1, 0); titleTextColor = errorTextColor = array.getColor(2, 0); detailsTextColor = array.getColor(3, 0); Drawable buttonNextIcon = array.getDrawable(4); if (buttonNextIcon != null) { this.buttonNextIcon = buttonNextIcon; } Drawable buttonFinishIcon = array.getDrawable(5); if (buttonFinishIcon != null) { this.buttonFinishIcon = buttonFinishIcon; } array.recycle(); }
private void initAttributes(TypedArray attributes) { finishedColor = attributes.getColor(R.styleable.RingProgress_finished_color, DEFAULT_FINISHED_COLOR); unfinishedColor = attributes.getColor(R.styleable.RingProgress_unfinished_color, DEFAULT_UNFINISHED_COLOR); innerTextColor = attributes.getColor(R.styleable.RingProgress_inner_text_color, DEFAULT_INNER_TEXT_COLOR); innerTextSize = attributes.getDimension( R.styleable.RingProgress_inner_text_size, DimensionUtils.sp2px(getResources(), DEFAULT_INNER_TEXT_SIZE)); max = attributes.getInt(R.styleable.RingProgress_ring_max, DEFAULT_MAX); progress = attributes.getInt(R.styleable.RingProgress_ring_progress, 0); finishedStrokeWidth = attributes.getDimension( R.styleable.RingProgress_finished_stroke_width, DimensionUtils.dp2px(getResources(), DEFAULT_FINISHED_STROKE_WIDTH)); unfinishedStrokeWidth = attributes.getDimension( R.styleable.RingProgress_unfinished_stroke_width, DimensionUtils.dp2px(getResources(), DEFAULT_UNFINISHED_STROKE_WIDTH)); innerText = attributes.getString(R.styleable.RingProgress_inner_text); startingDegree = attributes.getInt(R.styleable.RingProgress_starting_degree, 0); innerBackgroundColor = attributes.getColor(R.styleable.RingProgress_background_color, DEFAULT_BACKGROUND_COLOR); }
private void initAttributes(Context context, AttributeSet attributeSet) { TypedArray attr = getTypedArray(context, attributeSet, R.styleable.MaterialLetterIcon); if (attr != null) { try { mShapeColor = attr.getColor(R.styleable.MaterialLetterIcon_shape_color, DEFAULT_SHAPE_COLOR); mInitials = attr.getBoolean(R.styleable.MaterialLetterIcon_initials, DEFAULT_INITIALS_STATE); mInitialsNumber = attr.getInt(R.styleable.MaterialLetterIcon_initials_number, DEFAULT_INITIALS_NUMBER); mOriginalLetter = attr.getString(R.styleable.MaterialLetterIcon_letter); if (mOriginalLetter != null) { setLetter(mOriginalLetter); } mShapeType = attr.getInt(R.styleable.MaterialLetterIcon_shape_type, DEFAULT_SHAPE); mLetterColor = attr.getColor(R.styleable.MaterialLetterIcon_letter_color, DEFAULT_LETTER_COLOR); mLetterSize = attr.getInt(R.styleable.MaterialLetterIcon_letter_size, DEFAULT_LETTER_SIZE); mLettersNumber = attr.getInt(R.styleable.MaterialLetterIcon_letters_number, DEFAULT_LETTERS_NUMBER); } finally { attr.recycle(); } } }
private void setCustomAttributes(AttributeSet attrs) { TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.roundedimageview); mBorderThickness = a.getDimensionPixelSize(R.styleable.roundedimageview_border_thickness, 0); mBorderOutsideColor = a.getColor(R.styleable.roundedimageview_border_outside_color, defaultColor); mBorderInsideColor = a.getColor(R.styleable.roundedimageview_border_inside_color, defaultColor); }
/** * The contructor used with an inflater * * @param context * @param attrs */ public CircleFlowIndicator(Context context, AttributeSet attrs) { super(context, attrs); // Retrieve styles attributs TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleFlowIndicator); // Gets the inactive circle type, defaulting to "fill" int activeType = a.getInt(R.styleable.CircleFlowIndicator_activeType, STYLE_FILL); int activeDefaultColor = 0xFFFFFFFF; // Get a custom inactive color if there is one int activeColor = a.getColor(R.styleable.CircleFlowIndicator_activeColor, activeDefaultColor); // Gets the inactive circle type, defaulting to "stroke" int inactiveType = a.getInt(R.styleable.CircleFlowIndicator_inactiveType, STYLE_STROKE); int inactiveDefaultColor = 0x44FFFFFF; // Get a custom inactive color if there is one int inactiveColor = a.getColor(R.styleable.CircleFlowIndicator_inactiveColor, inactiveDefaultColor); // Retrieve the radius radius = a.getDimension(R.styleable.CircleFlowIndicator_radius, 4.0f); // Retrieve the fade out time fadeOutTime = a.getInt(R.styleable.CircleFlowIndicator_fadeOut, 0); initColors(activeColor, inactiveColor, activeType, inactiveType); }
public void init(AttributeSet attrs) { TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.SlantedTextView); mTextSize = array.getDimension(R.styleable.SlantedTextView_slantedTextSize, mTextSize); mTextColor = array.getColor(R.styleable.SlantedTextView_slantedTextColor, mTextColor); mSlantedLength = array.getDimension(R.styleable.SlantedTextView_slantedLength, mSlantedLength); mSlantedBackgroundColor = array.getColor(R.styleable.SlantedTextView_slantedBackgroundColor, mSlantedBackgroundColor); if (array.hasValue(R.styleable.SlantedTextView_slantedText)) { mSlantedText = array.getString(R.styleable.SlantedTextView_slantedText); } if (array.hasValue(R.styleable.SlantedTextView_slantedMode)) { mMode = array.getInt(R.styleable.SlantedTextView_slantedMode, 0); } array.recycle(); mPaint = new Paint(); mPaint.setStyle(Paint.Style.FILL); mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER)); mPaint.setAntiAlias(true); mPaint.setColor(mSlantedBackgroundColor); mTextPaint = new TextPaint(); mTextPaint.setAntiAlias(true); mTextPaint.setTextSize(mTextSize); mTextPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.ADD)); mTextPaint.setColor(mTextColor); mTextPaint.setTextAlign(Paint.Align.CENTER); }
private void init(Context context, AttributeSet attrs, int defStyle) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.IncreasingSeekBar, defStyle, 0); try { mOrientation = Orientation.fromId( typedArray.getInt( R.styleable.IncreasingSeekBar_isb_orientation, Orientation.HORIZONTAL.id)); mMaxRang = typedArray.getInt(R.styleable.IncreasingSeekBar_isb_max, DEF_MAX_RANG); mCurrValue = typedArray.getInt(R.styleable.IncreasingSeekBar_isb_curr_value, 0); mGapWidthPercent = typedArray.getFraction( R.styleable.IncreasingSeekBar_isb_gap_percent, 1, 1, DEF_GAP_PERCENT); mAllowUserTouch = typedArray.getBoolean(R.styleable.IncreasingSeekBar_isb_allow_user_touch, true); mDrawBorder = typedArray.getBoolean(R.styleable.IncreasingSeekBar_isb_draw_border, false); mBorderColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_border_color, DEF_COLOR); mBorderWidth = typedArray.getDimension(R.styleable.IncreasingSeekBar_isb_border_width, DEF_BORDER_WIDTH); mMainColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_color, DEF_COLOR); mStartColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_color_start, -1); mEndColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_color_end, -1); } finally { typedArray.recycle(); } mBarItemPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mBarItemPaint.setColor(mMainColor); mBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mBorderPaint.setStyle(Paint.Style.STROKE); mBorderPaint.setStrokeWidth(mBorderWidth); mBarItemPaint.setColor(mBorderColor); }
private void changeColorTheme(TypedArray colorSet) { changeInterfaceHeadColorTheme( colorSet.getColor(0, 0), colorSet.getColor(1, 0), colorSet.getColor(2, 0), colorSet.getColor(3, 0)); }
private void init(AttributeSet attrs) { if (isInEditMode()) { circleCount = 3; } circleRadius = (int) getResources().getDimension(R.dimen.fvp_default_circle_radius); circlePadding = (int) getResources().getDimension(R.dimen.fvp_default_circle_padding); int inactiveColor = ContextCompat.getColor(getContext(), R.color.fpi_default_indicator_inactive_color); int activeColor = ContextCompat.getColor(getContext(), R.color.fpi_default_indicator_active_color); int gravity = Gravity.CENTER; if (attrs != null) { TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.PageIndicator, 0, 0); circleRadius = (int) a.getDimension(R.styleable.PageIndicator_indicatorRadius, circleRadius); circlePadding = (int) a.getDimension(R.styleable.PageIndicator_indicatorPadding, circlePadding); inactiveColor = a.getColor(R.styleable.PageIndicator_indicatorInactiveColor, inactiveColor); activeColor = a.getColor(R.styleable.PageIndicator_indicatorActiveColor, activeColor); mGravity = a.getInt(R.styleable.PageIndicator_android_gravity, gravity); } activePaint = new Paint(Paint.ANTI_ALIAS_FLAG); activePaint.setColor(activeColor); inactivePaint = new Paint(Paint.ANTI_ALIAS_FLAG); inactivePaint.setColor(inactiveColor); }
private void loadTheme() { /* Default values */ mButtonNextIcon = getResources().getDrawable(R.drawable.ic_action_next_item); mButtonFinishIcon = getResources().getDrawable(R.drawable.ic_action_accept); /* Custom values */ int[] attrs = { R.attr.colorPrimary, R.attr.colorPrimaryDark, android.R.attr.textColorPrimary, android.R.attr.textColorSecondary, R.attr.sifNextIcon, R.attr.sifFinishIcon }; TypedArray array = obtainStyledAttributes(attrs); mTextFieldBackgroundColor = array.getColor(0, 0); mProgressBackgroundColor = array.getColor(1, 0); mTitleTextColor = mErrorTextColor = array.getColor(2, 0); mDetailsTextColor = array.getColor(3, 0); Drawable buttonNextIcon = array.getDrawable(4); if (buttonNextIcon != null) { mButtonNextIcon = buttonNextIcon; } Drawable buttonFinishIcon = array.getDrawable(5); if (buttonFinishIcon != null) { mButtonFinishIcon = buttonFinishIcon; } array.recycle(); }
public MaterialBreadcrumbsNavigation(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MaterialBreadcrumbsNavigation, 0, 0); textColor = a.getColor( R.styleable.MaterialBreadcrumbsNavigation_textColor, ContextCompat.getColor(context, R.color.default_text)); indicatorColor = a.getColor( R.styleable.MaterialBreadcrumbsNavigation_arrowColor, ContextCompat.getColor(context, R.color.default_indicator)); backgroundColor = a.getColor( R.styleable.MaterialBreadcrumbsNavigation_backgroundColor, ContextCompat.getColor(context, R.color.default_background)); a.recycle(); setOrientation(LinearLayout.HORIZONTAL); setGravity(Gravity.CENTER_VERTICAL); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.main_view, this, true); horizontalScrollView = (HorizontalScrollView) view.findViewById(R.id.horizontalScrollView); horizontalScrollView.setBackgroundColor(backgroundColor); viewGroup = (ViewGroup) findViewById(R.id.parent_view); list = new ArrayList<>(); }
public DashboardViewAttr(Context context, AttributeSet attrs, int defStyleAttr) { TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.DashboardView, defStyleAttr, 0); mTikeCount = ta.getInt(R.styleable.DashboardView_tikeCount, 48); mTextSize = ta.getDimensionPixelSize( PxUtils.spToPx(R.styleable.DashboardView_android_textSize, context), 24); mText = ta.getString(R.styleable.DashboardView_android_text); // progressHeight = // ta.getInt(PxUtils.dpToPx(R.styleable.DashboardView_progressHeight,context), 20); unit = ta.getString(R.styleable.DashboardView_Unit); textColor = ta.getColor( R.styleable.DashboardView_textColor, context.getResources().getColor(R.color.textColor)); background = ta.getColor(R.styleable.DashboardView_backgroundColor, 0); startColor = ta.getColor(R.styleable.DashboardView_startProgressColor, 0); endColor = ta.getColor(R.styleable.DashboardView_endProgressColor, 0); startNum = ta.getInt(R.styleable.DashboardView_startNumber, 0); maxNum = ta.getInt(R.styleable.DashboardView_maxNumber, 120); padding = ta.getInt(PxUtils.dpToPx(R.styleable.DashboardView_padding, context), 0); progressColor = ta.getColor( R.styleable.DashboardView_progressColor, context.getResources().getColor(R.color.skyblue)); ta.recycle(); }
/** * The contructor used with an inflater * * @param context * @param attrs */ public TitleFlowIndicator(Context context, AttributeSet attrs) { super(context, attrs); // Retrieve styles attributs TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitleFlowIndicator); // Retrieve the colors to be used for this view and apply them. int footerColor = a.getColor(R.styleable.TitleFlowIndicator_footerColor, FOOTER_COLOR); footerLineHeight = a.getDimension(R.styleable.TitleFlowIndicator_footerLineHeight, FOOTER_LINE_HEIGHT); footerTriangleHeight = a.getDimension(R.styleable.TitleFlowIndicator_footerTriangleHeight, FOOTER_TRIANGLE_HEIGHT); int selectedColor = a.getColor(R.styleable.TitleFlowIndicator_selectedColor, SELECTED_COLOR); boolean selectedBold = a.getBoolean(R.styleable.TitleFlowIndicator_selectedColor, SELECTED_BOLD); int textColor = a.getColor(R.styleable.TitleFlowIndicator_textColor, TEXT_COLOR); float textSize = a.getDimension(R.styleable.TitleFlowIndicator_textSize, TEXT_SIZE); float selectedSize = a.getDimension(R.styleable.TitleFlowIndicator_selectedSize, textSize); titlePadding = a.getDimension(R.styleable.TitleFlowIndicator_titlePadding, TITLE_PADDING); clipPadding = a.getDimension(R.styleable.TitleFlowIndicator_clipPadding, CLIP_PADDING); initDraw( textColor, textSize, selectedColor, selectedBold, selectedSize, footerLineHeight, footerColor); }
public static BeveledTileAttributeSet extractAttributes(Context context, AttributeSet attrs) { BeveledTileAttributeSet beveledTileAttributeSet = null; TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.BeveledTileView); try { int[] colorList = new int[BeveledTileDrawable.REQUIRED_COLOR_COUNT]; colorList[INNER_RECT_COLOR_INDICE] = attributesArray.getColor(R.styleable.BeveledTileView_innerRectColor, -1); colorList[LEFT_BEVEL_COLOR_INDICE] = attributesArray.getColor(R.styleable.BeveledTileView_leftBevelColor, -1); colorList[TOP_BEVEL_COLOR_INDICE] = attributesArray.getColor(R.styleable.BeveledTileView_topBevelColor, -1); colorList[RIGHT_BEVEL_COLOR_INDICE] = attributesArray.getColor(R.styleable.BeveledTileView_rightBevelColor, -1); colorList[BOTTOM_BEVEL_COLOR_INDICE] = attributesArray.getColor(R.styleable.BeveledTileView_bottomBevelColor, -1); float fillPercent = attributesArray.getFloat(R.styleable.BeveledTileView_fillPercentage, -1); beveledTileAttributeSet = new BeveledTileAttributeSet(colorList, fillPercent); } finally { attributesArray.recycle(); return beveledTileAttributeSet; } }
void init(Context context, AttributeSet attributeSet) { TypedArray attr = context.obtainStyledAttributes(attributeSet, R.styleable.FloatingActionButton, 0, 0); mColorNormal = attr.getColor( R.styleable.FloatingActionButton_fab_colorNormal, getColor(android.R.color.holo_blue_dark)); mColorPressed = attr.getColor( R.styleable.FloatingActionButton_fab_colorPressed, getColor(android.R.color.holo_blue_light)); mColorDisabled = attr.getColor( R.styleable.FloatingActionButton_fab_colorDisabled, getColor(android.R.color.darker_gray)); mSize = attr.getInt(R.styleable.FloatingActionButton_fab_size, SIZE_NORMAL); mIcon = attr.getResourceId(R.styleable.FloatingActionButton_fab_icon, 0); mTitle = attr.getString(R.styleable.FloatingActionButton_fab_title); mStrokeVisible = attr.getBoolean(R.styleable.FloatingActionButton_fab_stroke_visible, true); attr.recycle(); updateCircleSize(); mShadowRadius = getDimension(R.dimen.fab_shadow_radius); mShadowOffset = getDimension(R.dimen.fab_shadow_offset); updateDrawableSize(); updateBackground(); }