public AvatarImageBehavior(Context context, IAttributeSet attrs) { try { mContext = context; if (attrs != null) { TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.AvatarImageBehavior); mCustomFinalYPosition = a.GetDimension(Resource.Styleable.AvatarImageBehavior_finalYPosition, 0); mCustomStartXPosition = a.GetDimension(Resource.Styleable.AvatarImageBehavior_startXPosition, 0); mCustomStartToolbarPosition = a.GetDimension(Resource.Styleable.AvatarImageBehavior_startToolbarPosition, 0); mCustomStartHeight = a.GetDimension(Resource.Styleable.AvatarImageBehavior_startHeight, 0); mCustomFinalHeight = a.GetDimension(Resource.Styleable.AvatarImageBehavior_finalHeight, 0); a.Recycle(); } init(); mFinalLeftAvatarPadding = context.Resources.GetDimension(2); } catch (Exception exception) { Crashes.TrackError(exception); } }
public ChipView(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr) { TypedArray a = context.Theme.ObtainStyledAttributes(attrs, Resource.Styleable.ChipView, defStyleAttr, 0); if (a.HasValue(Resource.Styleable.ChipView_chip_text)) { _chipText = a.GetString(Resource.Styleable.ChipView_chip_text); } _hasIcon = a.GetBoolean(Resource.Styleable.ChipView_enable_icon, false); if (a.HasValue(Resource.Styleable.ChipView_chip_icon)) { _chipIcon = a.GetDrawable(Resource.Styleable.ChipView_chip_icon); } _closable = a.GetBoolean(Resource.Styleable.ChipView_closeable, false); _selectable = a.GetBoolean(Resource.Styleable.ChipView_chip_selectable, false); _backgroundColor = a.GetColor(Resource.Styleable.ChipView_chip_backgroundColor, ContextCompat.GetColor(context, Resource.Color.default_chip_background_color)); _selectedBackgroundColor = a.GetColor(Resource.Styleable.ChipView_chip_selectedBackgroundColor, ContextCompat.GetColor(context, Resource.Color.default_chip_background_clicked_color)); _textColor = a.GetColor(Resource.Styleable.ChipView_chip_text_color, ContextCompat.GetColor(context, Resource.Color.default_chip_text_color)); _selectedTextColor = a.GetColor(Resource.Styleable.ChipView_chip_selected_text_color, ContextCompat.GetColor(context, Resource.Color.default_chip_text_clicked_color)); _closeColor = a.GetColor(Resource.Styleable.ChipView_chip_close_color, ContextCompat.GetColor(context, Resource.Color.default_chip_close_inactive_color)); _selectedCloseColor = a.GetColor(Resource.Styleable.ChipView_chip_selected_close_color, ContextCompat.GetColor(context, Resource.Color.default_chip_close_clicked_color)); _cornerRadius = (int)a.GetDimension(Resource.Styleable.ChipView_chip_cornerRadius, Resources.GetDimension(Resource.Dimension.chip_height) / 2); _strokeSize = (int)a.GetDimension(Resource.Styleable.ChipView_chip_strokeSize, 0); _strokeColor = a.GetColor(Resource.Styleable.ChipView_chip_strokeColor, ContextCompat.GetColor(context, Resource.Color.default_chip_close_clicked_color)); if (a.HasValue(Resource.Styleable.ChipView_chip_iconText)) { _iconText = a.GetString(Resource.Styleable.ChipView_chip_iconText); } _iconTextColor = a.GetColor(Resource.Styleable.ChipView_chip_iconTextColor, ContextCompat.GetColor(context, Resource.Color.default_chip_background_clicked_color)); _iconTextBackgroundColor = a.GetColor(Resource.Styleable.ChipView_chip_iconTextBackgroundColor, ContextCompat.GetColor(context, Resource.Color.default_chip_close_clicked_color)); a.Recycle(); InitalizeViews(context); }
/** * Parse the attributes passed to the view from the XML * * @param a the attributes to parse */ private void ParseAttributes(TypedArray a) { DisplayMetrics metrics = Context.Resources.DisplayMetrics;// GetContext().getResources().getDisplayMetrics(); barWidth = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, barWidth, metrics); rimWidth = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, rimWidth, metrics); circleRadius = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, circleRadius, metrics); circleRadius = (int)a.GetDimension(Resource.Styleable.CircleProgressView_matProg_circleRadius, circleRadius); fillRadius = a.GetBoolean(Resource.Styleable.CircleProgressView_matProg_fillRadius, false); barWidth = (int)a.GetDimension(Resource.Styleable.CircleProgressView_matProg_barWidth, barWidth); rimWidth = (int)a.GetDimension(Resource.Styleable.CircleProgressView_matProg_rimWidth, rimWidth); float baseSpinSpeed = a.GetFloat(Resource.Styleable.CircleProgressView_matProg_spinSpeed, spinSpeed / 360.0f); spinSpeed = baseSpinSpeed * 360; barSpinCycleTime = a.GetInt(Resource.Styleable.CircleProgressView_matProg_barSpinCycleTime, (int)barSpinCycleTime); barColor = a.GetColor(Resource.Styleable.CircleProgressView_matProg_barColor, barColor); rimColor = a.GetColor(Resource.Styleable.CircleProgressView_matProg_rimColor, rimColor); linearProgress = a.GetBoolean(Resource.Styleable.CircleProgressView_matProg_linearProgress, false); if (a.GetBoolean(Resource.Styleable.CircleProgressView_matProg_progressIndeterminate, false)) { Spin(); } a.Recycle(); }
public void inititialize(Context context, IAttributeSet attrs, int defStyle) { mHandler = new SlidingHandler(this); TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.MultiDirectionSlidingDrawer, defStyle, 0); int orientation = a.GetInt(Resource.Styleable.MultiDirectionSlidingDrawer_direction, ORIENTATION_BTT); mVertical = (orientation == ORIENTATION_BTT || orientation == ORIENTATION_TTB); mBottomOffset = (int)a.GetDimension(Resource.Styleable.MultiDirectionSlidingDrawer_bottomOffset, 0.0f); mTopOffset = (int)a.GetDimension(Resource.Styleable.MultiDirectionSlidingDrawer_topOffset, 0.0f); mAllowSingleTap = a.GetBoolean(Resource.Styleable.MultiDirectionSlidingDrawer_allowSingleTap, true); mAnimateOnClick = a.GetBoolean(Resource.Styleable.MultiDirectionSlidingDrawer_animateOnClick, true); mInvert = (orientation == ORIENTATION_TTB || orientation == ORIENTATION_LTR); int handleId = a.GetResourceId(Resource.Styleable.MultiDirectionSlidingDrawer_handle, 0); if (handleId == 0) { throw new Java.Lang.IllegalArgumentException("The handle attribute is required and must refer " + "to a valid child."); } int contentId = a.GetResourceId(Resource.Styleable.MultiDirectionSlidingDrawer_content, 0); if (contentId == 0) { throw new Java.Lang.IllegalArgumentException("The content attribute is required and must refer " + "to a valid child."); } if (handleId == contentId) { throw new Java.Lang.IllegalArgumentException("The content and handle attributes must refer " + "to different children."); } mHandleId = handleId; mContentId = contentId; float density = Resources.DisplayMetrics.Density; mTapThreshold = (int)(TAP_THRESHOLD * density + 0.5f); mMaximumTapVelocity = (int)(MAXIMUM_TAP_VELOCITY * density + 0.5f); mMaximumMinorVelocity = (int)(MAXIMUM_MINOR_VELOCITY * density + 0.5f); mMaximumMajorVelocity = (int)(MAXIMUM_MAJOR_VELOCITY * density + 0.5f); mMaximumAcceleration = (int)(MAXIMUM_ACCELERATION * density + 0.5f); mVelocityUnits = (int)(VELOCITY_UNITS * density + 0.5f); if (mInvert) { mMaximumAcceleration = -mMaximumAcceleration; mMaximumMajorVelocity = -mMaximumMajorVelocity; mMaximumMinorVelocity = -mMaximumMinorVelocity; } a.Recycle(); AlwaysDrawnWithCacheEnabled = false; }
private void Init(Context context, IAttributeSet attrs, int style) { Resources res = Resources; density = res.DisplayMetrics.Density; TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.SlideToAction, style, 0); string tmp = a.GetString(Resource.Styleable.SlideToAction_slideToUnlockText); text = string.IsNullOrEmpty(tmp) ? text : tmp; rx = a.GetDimension(Resource.Styleable.SlideToAction_cornerRadiusX, rx); useDefaultCornerRadiusX = rx == 0; ry = a.GetDimension(Resource.Styleable.SlideToAction_cornerRadiusX, ry); useDefaultCornerRadiusY = ry == 0; backgroundColor = a.GetColor(Resource.Styleable.SlideToAction_slideToUnlockBackgroundColor, backgroundColor); textColor = a.GetColor(Resource.Styleable.SlideToAction_slideToUnlockTextColor, textColor); sliderColor = a.GetColor(Resource.Styleable.SlideToAction_sliderColor, sliderColor); cancelOnYExit = a.GetBoolean(Resource.Styleable.SlideToAction_cancelOnYExit, false); a.Recycle(); mRoundedRectPath = new Path(); mBackgroundPaint = new Paint(PaintFlags.AntiAlias); mBackgroundPaint.SetStyle(Paint.Style.Fill); mBackgroundPaint.Color = backgroundColor; mTextPaint = new Paint(PaintFlags.AntiAlias); mTextPaint.SetStyle(Paint.Style.Fill); mTextPaint.Color = textColor; mTextPaint.SetTypeface(Typeface.Create("Roboto-Thin", TypefaceStyle.Normal)); mSliderPaint = new Paint(PaintFlags.AntiAlias); mSliderPaint.SetStyle(Paint.Style.FillAndStroke); mSliderPaint.Color = sliderColor; mSliderPaint.StrokeWidth = 2 * density; if (!IsInEditMode) { // Edit mode does not support shadow layers // mSliderPaint.setShadowLayer(10.0f, 0.0f, 2.0f, 0xFF000000); //mSliderPaint.setMaskFilter(new EmbossMaskFilter(new float[]{1, 1, 1}, 0.4f, 10, 8.2f)); float[] direction = new float[] { 0.0f, -1.0f, 0.5f }; MaskFilter filter = new EmbossMaskFilter(direction, 0.8f, 15f, 1f); mSliderPaint.SetMaskFilter(filter); //mSliderPaint.setShader(new LinearGradient(8f, 80f, 30f, 20f, Color.RED,Color.WHITE, Shader.TileMode.MIRROR)); //mSliderPaint.setShader(new RadialGradient(8f, 80f, 90f, Color.RED,Color.WHITE, Shader.TileMode.MIRROR)); //mSliderPaint.setShader(new SweepGradient(80, 80, Color.RED, Color.WHITE)); //mSliderPaint.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.OUTER)); } }
public XLHRatingBar(Context context, IAttributeSet attrs) : base(context, attrs) { TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.XlHRatingBar); countNum = typedArray.GetInt(Resource.Styleable.XlHRatingBar_starCount, 5); countSelected = typedArray.GetInt(Resource.Styleable.XlHRatingBar_countSelected, 0); canEdit = typedArray.GetBoolean(Resource.Styleable.XlHRatingBar_canEdit, false); differentSize = typedArray.GetBoolean(Resource.Styleable.XlHRatingBar_differentSize, false); widthAndHeight = typedArray.GetDimension(Resource.Styleable.XlHRatingBar_widthAndHeight, ScreenUtils.dpToPxInt(0)); dividerWidth = typedArray.GetDimension(Resource.Styleable.XlHRatingBar_dividerWidth, ScreenUtils.dpToPxInt(0)); stateResId = typedArray.GetResourceId(Resource.Styleable.XlHRatingBar_stateResId, -1); initView(); }
protected override void OnCreate(Bundle savedInstanceState) { TypedArray styledAttributes = this.Theme.ObtainStyledAttributes( new int[] { Android.Resource.Attribute.ActionBarSize }); var actionbarHeight = (int)styledAttributes.GetDimension(0, 0); App.ScreenWidth = (int)Resources.DisplayMetrics.WidthPixels; // real pixels App.ScreenHeight = (int)Resources.DisplayMetrics.HeightPixels + actionbarHeight; // real pixels TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; RequestWindowFeature(WindowFeatures.NoTitle); StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.SetVmPolicy(builder.Build()); base.OnCreate(savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); //==================================== int uiOptions = (int)Window.DecorView.SystemUiVisibility; uiOptions |= (int)SystemUiFlags.LowProfile; uiOptions |= (int)SystemUiFlags.Fullscreen; uiOptions |= (int)SystemUiFlags.HideNavigation; uiOptions |= (int)SystemUiFlags.ImmersiveSticky; Window.DecorView.SystemUiVisibility = (StatusBarVisibility)uiOptions; //==================================== LoadApplication(new App()); }
public static void Init(Context context) { IWindowManager wm = context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>(); DisplayMetrics = new DisplayMetrics(); wm.DefaultDisplay.GetMetrics(DisplayMetrics); Point point = new Point(); wm.DefaultDisplay.GetSize(point); Width = point.X; Height = point.Y; Scale = context.Resources.DisplayMetrics.Density; TypedArray ta = context.Theme.ObtainStyledAttributes(new int[] { Android.Resource.Attribute.ActionBarSize }); ActionBarHeight = (int)ta.GetDimension(0, 0); int resourceId = context.Resources.GetIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { StatusBarHeight = context.Resources.GetDimensionPixelSize(resourceId); } }
public BottomSheet4StateBehaviour(Context context, IAttributeSet attrs) : base(context, attrs) { using (TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.BottomSheetBehavior_Layout)) { PeekHeight = a.GetDimensionPixelSize(Resource.Styleable.BottomSheetBehavior_Layout_behavior_peekHeight, 0); Hideable = a.GetBoolean(Resource.Styleable.BottomSheetBehavior_Layout_behavior_hideable, false); } /** * Getting the anchorPoint... */ AnchorPoint = DefaultAnchorPoint > PeekHeight ? DefaultAnchorPoint : 0; Collapsible = true; using (TypedArray a1 = context.ObtainStyledAttributes(attrs, Resource.Styleable.CustomBottomSheetBehavior)) { AnchorPoint = (int)a1.GetDimension(Resource.Styleable.CustomBottomSheetBehavior_anchorPoint, DefaultAnchorPoint); // _state = a1.GetInt(Resource.Styleable.CustomBottomSheetBehavior_defaultState, StateCollapsed); _state = a1.GetInt(Resource.Styleable.CustomBottomSheetBehavior_defaultState, StateAnchorPoint); } ViewConfiguration configuration = ViewConfiguration.Get(context); _minimumVelocity = configuration.ScaledMinimumFlingVelocity; _dragCallback = new ViewDragHelperCallback(this); }
/** * Instantiates a new holo circular progress bar. * * @param context the context * @param attrs the attrs * @param defStyle the def style */ public HoloCircularProgressBar(Context context, IAttributeSet Attrs, int DefStyle) : base(context, Attrs, DefStyle) { // load the styled attributes and set their properties TypedArray attributes = context.ObtainStyledAttributes(Attrs, Resource.Styleable.HoloCircularProgressBar, DefStyle, 0); if (attributes != null) { try { SetProgressColor(attributes.GetColor(Resource.Styleable.HoloCircularProgressBar_progress_color, Color.Cyan)); SetProgressBackgroundColor(attributes.GetColor(Resource.Styleable.HoloCircularProgressBar_progress_background_color, Color.Green)); SetProgress(attributes.GetFloat(Resource.Styleable.HoloCircularProgressBar_progress, 0.0f)); SetMarkerProgress(attributes.GetFloat(Resource.Styleable.HoloCircularProgressBar_marker_progress, 0.0f)); SetWheelSize((int)attributes.GetDimension(Resource.Styleable.HoloCircularProgressBar_stroke_width, 10)); SetThumbEnabled(attributes.GetBoolean(Resource.Styleable.HoloCircularProgressBar_thumb_visible, true)); SetMarkerEnabled(attributes.GetBoolean(Resource.Styleable.HoloCircularProgressBar_marker_visible, true)); _gravity = (GravityFlags)attributes.GetInt(Resource.Styleable.HoloCircularProgressBar_android_gravity, (int)GravityFlags.Center); } finally { // make sure recycle is always called. attributes.Recycle(); } } _thumbRadius = _circleStrokeWidth * 2; UpdateBackgroundColor(); UpdateMarkerColor(); UpdateProgressColor(); // the view has now all properties and can be drawn _isInitializing = false; }
private void Init(Context context, IAttributeSet attrs) { anim = new CircleBarAnim(this); defaultSize = DpOrPxUtils.dip2px(context, 100); barWidth = DpOrPxUtils.dip2px(context, 10); TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.CircleBarView); progressColor = typedArray.GetColor(Resource.Styleable.CircleBarView_progress_color, Color.Green); //默认为绿色 bgColor = typedArray.GetColor(Resource.Styleable.CircleBarView_bg_color, Color.Gray); //默认为灰色 startAngle = typedArray.GetFloat(Resource.Styleable.CircleBarView_start_angle, 0); //默认为0 sweepAngle = typedArray.GetFloat(Resource.Styleable.CircleBarView_sweep_angle, 360); //默认为360 barWidth = typedArray.GetDimension(Resource.Styleable.CircleBarView_bar_width, DpOrPxUtils.dip2px(context, 10)); //默认为10dp typedArray.Recycle(); //typedArray用完之后需要回收,防止内存泄漏 progressPaint = new Paint(); progressPaint.StrokeCap = Paint.Cap.Round; progressPaint.SetStyle(Paint.Style.Stroke); //只描边,不填充 progressPaint.Color = progressColor; progressPaint.AntiAlias = true; //设置抗锯齿 progressPaint.StrokeWidth = barWidth; //随便设置一个画笔宽度,看看效果就好,之后会通过attr自定义属性进行设置 bgPaint = new Paint(); bgPaint.StrokeCap = Paint.Cap.Round; bgPaint.SetStyle(Paint.Style.Stroke); //只描边,不填充 bgPaint.Color = bgColor; bgPaint.AntiAlias = true; //设置抗锯齿 bgPaint.StrokeWidth = barWidth; NowProgressNum = 0; progressNum = 0; maxNum = 100;//也是随便设的 }
public PinWidget(Context context, IAttributeSet attribs, int defStyleAttr) : base(context, attribs, defStyleAttr) { ShouldRedraw = false; this.FillViewport = true; ScrollBarStyle = ScrollbarStyles.OutsideInset; TypedArray array = context.ObtainStyledAttributes(attribs, Resource.Styleable.PinView); var method = array.GetString(Resource.Styleable.PinView_onPinCompleted); PinListener = new PrivatePinListener(method, this); DigitCount = (uint)array.GetInt(Resource.Styleable.PinView_digitCount, PinDefaults.DIGIT_COUNT); DisplayMetrics metrics = Resources.DisplayMetrics; // Digit dimensions DigitWidth = array.GetDimensionPixelSize(Resource.Styleable.PinView_digitWidth, (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, PinDefaults.DIGIT_WIDTH, metrics)); DigitHeight = array.GetDimensionPixelSize(Resource.Styleable.PinView_digitHeight, (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, PinDefaults.DIGIT_HEIGHT, metrics)); DigitSpacing = array.GetDimensionPixelSize(Resource.Styleable.PinView_digitSpacing, (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, PinDefaults.DIGIT_SPACING, metrics)); TextSize = array.GetDimensionPixelSize(Resource.Styleable.PinView_textSize, (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, PinDefaults.TEXT_SIZE, metrics)); TypedValue resolvedColor = new TypedValue(); Resources.Theme theme = context.Theme; // Colors theme.ResolveAttribute(Android.Resource.Attribute.TextColorPrimary, resolvedColor, true); TextColor = array.GetColor(Resource.Styleable.PinView_textColor, resolvedColor.ResourceId > 0 ? ContextCompat.GetColor(context, resolvedColor.ResourceId) : resolvedColor.Data); DigitBorderColor = array.GetColor(Resource.Styleable.PinView_borderColor, TextColor); resolvedColor = new TypedValue(); theme.ResolveAttribute(Android.Resource.Attribute.ColorAccent, resolvedColor, true); AccentColor = array.GetColor(Resource.Styleable.PinView_accentColor, resolvedColor.ResourceId > 0 ? ContextCompat.GetColor(context, resolvedColor.ResourceId) : resolvedColor.Data); resolvedColor = new TypedValue(); theme.ResolveAttribute(Android.Resource.Attribute.WindowBackground, resolvedColor, true); DigitBackgroundColor = array.GetColor(Resource.Styleable.PinView_digitBackgroundColor, resolvedColor.ResourceId > 0 ? ContextCompat.GetColor(context, resolvedColor.ResourceId) : resolvedColor.Data); AccentHeight = (int)array.GetDimension(Resource.Styleable.PinView_accentHeight, TypedValue.ApplyDimension(ComplexUnitType.Dip, PinDefaults.ACCENT_HEIGHT, metrics)); array.Recycle(); _mainLayout = new LinearLayout(Context); _pinInputField = new EditText(Context); var container = new FrameLayout(Context); container.AddView(_mainLayout); container.AddView(_pinInputField); this.AddView(container); ShouldRedraw = true; }
private void Init(Context context, IAttributeSet attrs) { TypedArray ta = context.ObtainStyledAttributes(attrs, Resource.Styleable.TriangleLabelView); this.topPadding = ta.GetDimension(Resource.Styleable.TriangleLabelView_labelTopPadding, 7f.DpToPx(this.Context)); this.centerPadding = ta.GetDimension(Resource.Styleable.TriangleLabelView_labelCenterPadding, 3f.DpToPx(this.Context)); this.bottomPadding = ta.GetDimension(Resource.Styleable.TriangleLabelView_labelBottomPadding, 3f.DpToPx(this.Context)); this.triangleBackgroundColor = ta.GetColor(Resource.Styleable.TriangleLabelView_backgroundColor, Color.ParseColor("#66000000")); this.primary.Color = ta.GetColor(Resource.Styleable.TriangleLabelView_primaryTextColor, Color.White); this.secondary.Color = ta.GetColor(Resource.Styleable.TriangleLabelView_secondaryTextColor, Color.White); this.primary.Size = ta.GetDimension(Resource.Styleable.TriangleLabelView_primaryTextSize, 11f.SpToPx(this.Context)); this.secondary.Size = ta.GetDimension(Resource.Styleable.TriangleLabelView_secondaryTextSize, 8f.SpToPx(this.Context)); var primaryText = ta.GetString(Resource.Styleable.TriangleLabelView_primaryText); if (!string.IsNullOrEmpty(primaryText)) { this.primary.Text = primaryText; } var secondaryText = ta.GetString(Resource.Styleable.TriangleLabelView_secondaryText); if (!string.IsNullOrEmpty(secondaryText)) { this.secondary.Text = secondaryText; } this.primary.Style = ta.GetInt(Resource.Styleable.TriangleLabelView_primaryTextStyle, 2); this.secondary.Style = ta.GetInt(Resource.Styleable.TriangleLabelView_secondaryTextStyle, 0); this.Corner = (Corner)ta.GetInt(Resource.Styleable.TriangleLabelView_corner, 1); ta.Recycle(); this.primary.Initialize(); this.secondary.Initialize(); this.trianglePaint = new Paint(PaintFlags.AntiAlias); this.trianglePaint.Color = this.triangleBackgroundColor; this.primary.ResetStatus(); this.secondary.ResetStatus(); }
private void InitialDefaultValues(IAttributeSet attrs) { // Dimensions mRowHeaderWidth = (int)Resources.GetDimension(Resource.Dimension.default_row_header_width); mColumnHeaderHeight = (int)Resources.GetDimension(Resource.Dimension.default_column_header_height); // Colors mSelectedColor = ContextCompat.GetColor(Context, Resource.Color.table_view_default_selected_background_color); mUnSelectedColor = ContextCompat.GetColor(Context, Resource.Color.table_view_default_unselected_background_color); mShadowColor = ContextCompat.GetColor(Context, Resource.Color.table_view_default_shadow_background_color); if (attrs == null) { // That means TableView is created programmatically. return; } // Get values from xml attributes TypedArray a = Context.Theme.ObtainStyledAttributes(attrs, Resource.Styleable.TableView, 0, 0); try { // Dimensions mRowHeaderWidth = (int)a.GetDimension(Resource.Styleable.TableView_row_header_width, mRowHeaderWidth); mColumnHeaderHeight = (int)a.GetDimension(Resource.Styleable.TableView_column_header_height, mColumnHeaderHeight); // Colors mSelectedColor = a.GetColor(Resource.Styleable.TableView_selected_color, mSelectedColor); mUnSelectedColor = a.GetColor(Resource.Styleable.TableView_unselected_color, mUnSelectedColor); mShadowColor = a.GetColor(Resource.Styleable.TableView_shadow_color, mShadowColor); mSeparatorColor = a.GetColor(Resource.Styleable.TableView_separator_color, ContextCompat.GetColor(Context, Resource.Color.table_view_default_separator_color)); // Booleans mShowVerticalSeparators = a.GetBoolean(Resource.Styleable.TableView_show_vertical_separator, mShowVerticalSeparators); mShowHorizontalSeparators = a.GetBoolean(Resource.Styleable.TableView_show_horizontal_separator, mShowHorizontalSeparators); } finally { a.Recycle(); } }
protected override void UseStyleAttributes(TypedArray attrs) { var titleText = attrs.GetString(Resource.Styleable.TwoLineTextOnlyView_textForTitle); Color titleTextColor = attrs.GetColor(Resource.Styleable.TwoLineTextOnlyView_textColorForTitle, -1); var titleTextSize = attrs.GetDimension(Resource.Styleable.TwoLineTextOnlyView_textSizeForTitle, -1); var titleTextStyle = attrs.GetInt(Resource.Styleable.TwoLineTextOnlyView_textStyleForTitle, (int)Enum.ToObject(typeof(TypefaceStyle), TypefaceStyle.Normal)); var titleTypeface = attrs.GetInt(Resource.Styleable.TwoLineTextOnlyView_typefaceForTitle, 0); var titleFontFamily = attrs.GetString(Resource.Styleable.TwoLineTextOnlyView_fontFamilyForTitle); var subtitleText = attrs.GetString(Resource.Styleable.TwoLineTextOnlyView_textForSubtitle); Color subtitleTextColor = attrs.GetColor(Resource.Styleable.TwoLineTextOnlyView_textColorForSubtitle, -1); var subtitleTextSize = attrs.GetDimension(Resource.Styleable.TwoLineTextOnlyView_textSizeForSubtitle, -1); var subtitleTextStyle = attrs.GetInt(Resource.Styleable.TwoLineTextOnlyView_textStyleForSubtitle, (int)Enum.ToObject(typeof(TypefaceStyle), TypefaceStyle.Normal)); var subtitleTypeface = attrs.GetInt(Resource.Styleable.TwoLineTextOnlyView_typefaceForSubtitle, 0); var subtitleFontFamily = attrs.GetString(Resource.Styleable.TwoLineTextOnlyView_fontFamilyForSubtitle); attrs.Recycle(); PrepareTextViewWithAttrValues(TitleView, titleText, titleTextColor, titleTextSize, titleTextStyle, titleTypeface, titleFontFamily); PrepareTextViewWithAttrValues(SubtitleView, subtitleText, subtitleTextColor, subtitleTextSize, subtitleTextStyle, subtitleTypeface, subtitleFontFamily); }
protected void initByAttributes(TypedArray attributes) { finishedStrokeColor = attributes.GetColor(Resource.Styleable.DonutProgress_donut_finished_color, default_finished_color); unfinishedStrokeColor = attributes.GetColor(Resource.Styleable.DonutProgress_donut_unfinished_color, default_unfinished_color); showText = attributes.GetBoolean(Resource.Styleable.DonutProgress_donut_show_text, true); attributeResourceId = attributes.GetResourceId(Resource.Styleable.DonutProgress_donut_inner_drawable, 0); setMax(attributes.GetInt(Resource.Styleable.DonutProgress_donut_max, default_max)); setProgress(attributes.GetFloat(Resource.Styleable.DonutProgress_donut_progress, 0)); finishedStrokeWidth = attributes.GetDimension(Resource.Styleable.DonutProgress_donut_finished_stroke_width, default_stroke_width); unfinishedStrokeWidth = attributes.GetDimension(Resource.Styleable.DonutProgress_donut_unfinished_stroke_width, default_stroke_width); if (showText) { if (attributes.GetString(Resource.Styleable.DonutProgress_donut_prefix_text) != null) { prefixText = attributes.GetString(Resource.Styleable.DonutProgress_donut_prefix_text); } if (attributes.GetString(Resource.Styleable.DonutProgress_donut_suffix_text) != null) { suffixText = attributes.GetString(Resource.Styleable.DonutProgress_donut_suffix_text); } if (attributes.GetString(Resource.Styleable.DonutProgress_donut_text) != null) { text = attributes.GetString(Resource.Styleable.DonutProgress_donut_text); } textColor = attributes.GetColor(Resource.Styleable.DonutProgress_donut_text_color, default_text_color); textSize = attributes.GetDimension(Resource.Styleable.DonutProgress_donut_text_size, default_text_size); innerBottomTextSize = attributes.GetDimension(Resource.Styleable.DonutProgress_donut_inner_bottom_text_size, default_inner_bottom_text_size); innerBottomTextColor = attributes.GetColor(Resource.Styleable.DonutProgress_donut_inner_bottom_text_color, default_inner_bottom_text_color); innerBottomText = attributes.GetString(Resource.Styleable.DonutProgress_donut_inner_bottom_text); } innerBottomTextSize = attributes.GetDimension(Resource.Styleable.DonutProgress_donut_inner_bottom_text_size, default_inner_bottom_text_size); innerBottomTextColor = attributes.GetColor(Resource.Styleable.DonutProgress_donut_inner_bottom_text_color, default_inner_bottom_text_color); innerBottomText = attributes.GetString(Resource.Styleable.DonutProgress_donut_inner_bottom_text); startingDegree = attributes.GetInt(Resource.Styleable.DonutProgress_donut_circle_starting_degree, default_startingDegree); innerBackgroundColor = attributes.GetColor(Resource.Styleable.DonutProgress_donut_background_color, default_inner_background_color); }
public void ApplyTypedArray(TypedArray arr) { Gravity = (GravityFlags)arr.GetInt(Resource.Styleable.odometer_android_gravity, (int)Gravity); ShadowColor = arr.GetColor(Resource.Styleable.odometer_android_shadowColor, ShadowColor); ShadowDx = arr.GetFloat(Resource.Styleable.odometer_android_shadowDx, ShadowDx); ShadowDy = arr.GetFloat(Resource.Styleable.odometer_android_shadowDy, ShadowDy); ShadowRadius = arr.GetFloat(Resource.Styleable.odometer_android_shadowRadius, ShadowRadius); Text = arr.GetString(Resource.Styleable.odometer_android_text); TextColor = arr.GetColor(Resource.Styleable.odometer_android_textColor, TextColor); TextSize = arr.GetDimension(Resource.Styleable.odometer_android_textSize, TextSize); TextStyle = (TypefaceStyle)arr.GetInt(Resource.Styleable.odometer_android_textStyle, (int)TextStyle); }
private void init(Context context, IAttributeSet attributeSet, int defStyle) { if (attributeSet == null) { return; } float density = context.Resources.DisplayMetrics.Density; TypedArray typedArray = context.ObtainStyledAttributes(attributeSet, Resource.Styleable.UnderlinedTextView, defStyle, 0); _color = typedArray.GetColor(Resource.Styleable.UnderlinedTextView_underlineColor, new Color(0, 0, 0)); _strokeWidth = typedArray.GetDimension(Resource.Styleable.UnderlinedTextView_underlineWidth, density * 2); _margin = typedArray.GetDimension(Resource.Styleable.UnderlinedTextView_underlineMarginTop, density * 2); typedArray.Recycle(); _lineBoundsRect = new Rect(); _underlinePaint = new Paint(); _underlinePaint.SetStyle(Android.Graphics.Paint.Style.Stroke); _underlinePaint.Color = _color; _underlinePaint.StrokeWidth = _strokeWidth; }
public AvatarImageBehavior(Context Context, IAttributeSet attrs) { context = Context; if (attrs != null) { TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.AvatarImageBehavior); customFinalYPosition = typedArray.GetDimension(Resource.Styleable.AvatarImageBehavior_finalYPosition, 0); customStartXPosition = typedArray.GetDimension(Resource.Styleable.AvatarImageBehavior_startXPosition, 0); customStartToolbarPosition = typedArray.GetDimension(Resource.Styleable.AvatarImageBehavior_startToolbarPosition, 0); customStartHeight = typedArray.GetDimension(Resource.Styleable.AvatarImageBehavior_startHeight, 0); customFinalHeight = typedArray.GetDimension(Resource.Styleable.AvatarImageBehavior_finalHeight, 0); typedArray.Recycle(); } Init(); finalLeftAvatarPadding = context.Resources.GetDimension( Resource.Dimension.spacing_normal); }
public RealtimeBlurView(Context context, IAttributeSet attrs) : base(context, attrs) { TypedArray a = context.ObtainStyledAttributes(attrs, R.Styleable.RealtimeBlurView); mBlurRadius = a.GetDimension(R.Styleable.RealtimeBlurView_realtimeBlurRadius, TypedValue.ApplyDimension(ComplexUnitType.Dip, 10, context.Resources.DisplayMetrics)); mDownsampleFactor = a.GetFloat(R.Styleable.RealtimeBlurView_realtimeDownsampleFactor, 4); mOverlayColor = a.GetColor(R.Styleable.RealtimeBlurView_realtimeOverlayColor, Color.Argb(0xaa, 255, 255, 255).ToArgb()); a.Recycle(); mPaint = new Paint(); preDrawListener = new MyPreDrawListener(this); }
public LinePageIndicator(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle) { if (IsInEditMode) { return; } //Load defaults from resources int defaultSelectedColor = Resources.GetColor(Resource.Color.default_line_indicator_selected_color); int defaultUnselectedColor = Resources.GetColor(Resource.Color.default_line_indicator_unselected_color); float defaultLineWidth = Resources.GetDimension(Resource.Dimension.default_line_indicator_line_width); float defaultGapWidth = Resources.GetDimension(Resource.Dimension.default_line_indicator_gap_width); float defaultStrokeWidth = Resources.GetDimension(Resource.Dimension.default_line_indicator_stroke_width); bool defaultCentered = Resources.GetBoolean(Resource.Boolean.default_line_indicator_centered); //Retrieve styles attributes TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.LinePageIndicator, defStyle, 0); centered = a.GetBoolean(Resource.Styleable.LinePageIndicator_centered, defaultCentered); lineWidth = a.GetDimension(Resource.Styleable.LinePageIndicator_lineWidth, defaultLineWidth); gapWidth = a.GetDimension(Resource.Styleable.LinePageIndicator_gapWidth, defaultGapWidth); SetStrokeWidth(a.GetDimension(Resource.Styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth)); paintUnselected.Color = a.GetColor(Resource.Styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor); paintSelected.Color = a.GetColor(Resource.Styleable.LinePageIndicator_selectedColor, defaultSelectedColor); Drawable background = a.GetDrawable(Resource.Styleable.LinePageIndicator_android_background); if (background != null) { SetBackgroundDrawable(background); } a.Recycle(); ViewConfiguration configuration = ViewConfiguration.Get(context); mTouchSlop = ViewConfigurationCompat.GetScaledPagingTouchSlop(configuration); }
public LoadingView(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr) { mRing = new Ring(); bounds = new Rect(); mPaint = new Paint(); mPaint = new Paint(PaintFlags.AntiAlias); mPaint.SetStyle(Paint.Style.Stroke); mPaint.StrokeWidth = mRing.strokeWidth; animatorListener = new CustomAnimatorListener(this); if (attrs != null) { TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.LoadingView, 0, 0); setColor(a.GetInt(Resource.Styleable.LoadingView_loadding_color, DEFAULT_COLOR)); setRingStyle(a.GetInt(Resource.Styleable.LoadingView_ring_style, RING_STYLE_SQUARE)); setProgressStyle(a.GetInt(Resource.Styleable.LoadingView_progress_style, PROGRESS_STYLE_MATERIAL)); setStrokeWidth(a.GetDimension(Resource.Styleable.LoadingView_ring_width, dp2px(STROKE_WIDTH))); setCenterRadius(a.GetDimension(Resource.Styleable.LoadingView_ring_radius, dp2px(CENTER_RADIUS))); a.Recycle(); } }
protected void initAttrs(IAttributeSet attrs) { TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.superrecyclerview); try { mClipToPadding = a.GetBoolean(Resource.Styleable.superrecyclerview_recyclerClipToPadding, false); mPadding = (int)a.GetDimension(Resource.Styleable.superrecyclerview_recyclerPadding, -1.0f); mPaddingTop = (int)a.GetDimension(Resource.Styleable.superrecyclerview_recyclerPaddingTop, 0.0f); mPaddingBottom = (int)a.GetDimension(Resource.Styleable.superrecyclerview_recyclerPaddingBottom, 0.0f); mPaddingLeft = (int)a.GetDimension(Resource.Styleable.superrecyclerview_recyclerPaddingLeft, 0.0f); mPaddingRight = (int)a.GetDimension(Resource.Styleable.superrecyclerview_recyclerPaddingRight, 0.0f); mScrollbarStyle = a.GetInteger(Resource.Styleable.superrecyclerview_scrollbarStyle, -1); mScrollbar = a.GetInteger(Resource.Styleable.superrecyclerview_scrollbars, -1); mEmptyId = a.GetResourceId(Resource.Styleable.superrecyclerview_layout_empty, 0); mProgressId = a.GetResourceId(Resource.Styleable.superrecyclerview_layout_progress, 0); mErrorId = a.GetResourceId(Resource.Styleable.superrecyclerview_layout_error, Resource.Layout.common_net_error_view); } finally { a.Recycle(); } }
private void init(IAttributeSet attrs) { TextChanged += OnTextChanged; if (attrs == null) { mEmojiconSize = (int)TextSize; } else { TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.Emojicon); mEmojiconSize = (int)a.GetDimension(Resource.Styleable.Emojicon_emojiconSize, TextSize); a.Recycle(); } Text = base.Text; }
public Marker(Context context, IAttributeSet attrs, int defStyleAttr, String maxValue, int thumbSize, int separation) : base(context, attrs, defStyleAttr) { Visibility = ViewStates.Visible; DisplayMetrics displayMetrics = context.Resources.DisplayMetrics; TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.DiscreteSeekBar, Resource.Attribute.discreteSeekBarStyle, Resource.Style.Widget_DiscreteSeekBar); int padding = (int)(PADDING_DP * displayMetrics.Density) * 2; int textAppearanceId = a.GetResourceId(Resource.Styleable.DiscreteSeekBar_dsb_indicatorTextAppearance, Resource.Style.Widget_DiscreteIndicatorTextAppearance); mNumber = new TextView(context); //Add some padding to this textView so the bubble has some space to breath mNumber.SetPadding(padding, 0, padding, 0); mNumber.SetTextAppearance(context, textAppearanceId); mNumber.Gravity = GravityFlags.Center; mNumber.Text = maxValue; mNumber.SetMaxLines(1); mNumber.SetSingleLine(true); SeekBarCompat.SetTextDirection(mNumber, (int)TextDirectionLocale); mNumber.Visibility = ViewStates.Invisible; //add some padding for the elevation shadow not to be clipped //I'm sure there are better ways of doing this... SetPadding(padding, padding, padding, padding); ResetSizes(maxValue); mSeparation = separation; ColorStateList color = a.GetColorStateList(Resource.Styleable.DiscreteSeekBar_dsb_indicatorColor); mMarkerDrawable = new MarkerDrawable(color, thumbSize); mMarkerDrawable.SetCallback(this); mMarkerDrawable.SetMarkerListener(this); mMarkerDrawable.SetExternalOffset(padding); //Elevation for anroid 5+ float elevation = a.GetDimension(Resource.Styleable.DiscreteSeekBar_dsb_indicatorElevation, ELEVATION_DP * displayMetrics.Density); ViewCompat.SetElevation(this, elevation); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { SeekBarCompat.SetOutlineProvider(this, mMarkerDrawable); } a.Recycle(); }
protected override void UseStyleAttributes(TypedArray attrs) { var titleText = attrs.GetString(Resource.Styleable.SingleLineIconWithTextView_textForTitle); var titleTextColor = attrs.GetColor(Resource.Styleable.SingleLineIconWithTextView_textColorForTitle, -1); var titleTextSize = attrs.GetDimension(Resource.Styleable.SingleLineIconWithTextView_textSizeForTitle, -1); var titleTextStyle = attrs.GetInt(Resource.Styleable.SingleLineIconWithTextView_textStyleForTitle, (int)Enum.ToObject(typeof(TypefaceStyle), TypefaceStyle.Normal)); var titleTypeface = attrs.GetInt(Resource.Styleable.SingleLineIconWithTextView_typefaceForTitle, 0); var titleFontFamily = attrs.GetString(Resource.Styleable.SingleLineIconWithTextView_fontFamilyForTitle); var iconSrc = attrs.GetDrawable(Resource.Styleable.SingleLineIconWithTextView_iconSrc); var iconTint = attrs.GetColor(Resource.Styleable.SingleLineIconWithTextView_iconTint, -1); attrs.Recycle(); PrepareTextViewWithAttrValues(viewTitle, titleText, titleTextColor, titleTextSize, titleTextStyle, titleTypeface, titleFontFamily); PrepareIconViewWithAttrValues(iconSrc, iconTint); }
private void init(IAttributeSet attrs) { if (attrs == null) { mEmojiconSize = (int)TextSize; } else { TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.Emojicon); mEmojiconSize = (int)a.GetDimension(Resource.Styleable.Emojicon_emojiconSize, TextSize); mTextStart = a.GetInteger(Resource.Styleable.Emojicon_emojiconTextStart, 0); mTextLength = a.GetInteger(Resource.Styleable.Emojicon_emojiconTextLength, -1); a.Recycle(); } Text = base.Text; }
public WatermarkedImageView(Context context, IAttributeSet attrs) : base(context, attrs) { TypedArray typedArray = context.Theme.ObtainStyledAttributes(attrs, Resource.Styleable.CustomImageView, 0, 0); try { //Retrieve assigned attributes WatermarkText = typedArray.GetString(Resource.Styleable.CustomImageView_watermarkText); WatermarkPosition = (WatermarkPosition)typedArray.GetInteger(Resource.Styleable.CustomImageView_watermarkPosition, 0); WatermarkTextSize = typedArray.GetDimension(Resource.Styleable.CustomImageView_watermarkTextSize, 48f); typedArray.Recycle(); } catch (Exception e) { Log.Error("WatermarkedImageView", e.Message); } }
public TagGroup(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr) { default_border_stroke_width = dp2px(0.5f); default_text_size = sp2px(13.0f); default_horizontal_spacing = dp2px(8.0f); default_vertical_spacing = dp2px(4.0f); default_horizontal_padding = dp2px(12.0f); default_vertical_padding = dp2px(3.0f); // Load styled attributes. TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.TagGroup, defStyleAttr, Resource.Style.TagGroup); try { isAppendMode = a.GetBoolean(Resource.Styleable.TagGroup_atg_isAppendMode, false); inputHint = a.GetText(Resource.Styleable.TagGroup_atg_inputHint); borderColor = a.GetColor(Resource.Styleable.TagGroup_atg_borderColor, default_border_color); textColor = a.GetColor(Resource.Styleable.TagGroup_atg_textColor, default_text_color); backgroundColor = a.GetColor(Resource.Styleable.TagGroup_atg_backgroundColor, default_background_color); dashBorderColor = a.GetColor(Resource.Styleable.TagGroup_atg_dashBorderColor, default_dash_border_color); inputHintColor = a.GetColor(Resource.Styleable.TagGroup_atg_inputHintColor, default_input_hint_color); inputTextColor = a.GetColor(Resource.Styleable.TagGroup_atg_inputTextColor, default_input_text_color); checkedBorderColor = a.GetColor(Resource.Styleable.TagGroup_atg_checkedBorderColor, default_checked_border_color); checkedTextColor = a.GetColor(Resource.Styleable.TagGroup_atg_checkedTextColor, default_checked_text_color); checkedMarkerColor = a.GetColor(Resource.Styleable.TagGroup_atg_checkedMarkerColor, default_checked_marker_color); checkedBackgroundColor = a.GetColor(Resource.Styleable.TagGroup_atg_checkedBackgroundColor, default_checked_background_color); pressedBackgroundColor = a.GetColor(Resource.Styleable.TagGroup_atg_pressedBackgroundColor, default_pressed_background_color); borderStrokeWidth = a.GetDimension(Resource.Styleable.TagGroup_atg_borderStrokeWidth, default_border_stroke_width); textSize = a.GetDimension(Resource.Styleable.TagGroup_atg_textSize, default_text_size); horizontalSpacing = (int)a.GetDimension(Resource.Styleable.TagGroup_atg_horizontalSpacing, default_horizontal_spacing); verticalSpacing = (int)a.GetDimension(Resource.Styleable.TagGroup_atg_verticalSpacing, default_vertical_spacing); horizontalPadding = (int)a.GetDimension(Resource.Styleable.TagGroup_atg_horizontalPadding, default_horizontal_padding); verticalPadding = (int)a.GetDimension(Resource.Styleable.TagGroup_atg_verticalPadding, default_vertical_padding); } finally { a.Recycle(); } if (isAppendMode) { // Append the initial INPUT tag. appendInputTag(); Click += (sender, e) => { submitTag(); }; } }
private void initAttributes(Context context, IAttributeSet attributeSet) { TypedArray attr = getTypedArray(context, attributeSet, Resource.Styleable.FlatButton); if (attr == null) { return; } try { float defValue = Resources.GetDimension(Resource.Dimension.corner_radius); cornerRadius = attr.GetDimension(Resource.Styleable.FlatButton_pb_cornerRadius, defValue); mNormalDrawable.AddState(new int[] { Android.Resource.Attribute.StatePressed }, createPressedDrawable(attr)); mNormalDrawable.AddState(new int[] { }, createNormalDrawable(attr)); } finally { attr.Recycle(); } }