public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { base.GetItemOffsets(outRect, view, parent, state); if (this.GetOrientation(parent) == LinearLayoutManager.Vertical) { outRect.Set(0, 0, 0, this.divider.IntrinsicHeight); } else { outRect.Set(0, 0, this.divider.IntrinsicWidth, 0); } }
public override void GetItemOffsets (Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { if (orientation == VerticalList) { outRect.Set (0, 0, 0, divider.IntrinsicHeight); } else { outRect.Set (0, 0, divider.IntrinsicWidth, 0); } }
public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { var holder = parent.GetChildViewHolder(view) as ViewHolder; if (!CellIsVisible(holder?.RowInfo.Cell)) { return; } outRect.Set(0, _drawable.IntrinsicHeight, 0, 0); }
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (ChildCount == 0 || GetChildAt(0) is not View child) { base.OnMeasure(widthMeasureSpec, heightMeasureSpec); return; } _viewBounds.Set( 0, 0, MeasureSpec.GetSize(widthMeasureSpec), MeasureSpec.GetSize(heightMeasureSpec)); child.Measure(widthMeasureSpec, heightMeasureSpec); SetMeasuredDimension(child.MeasuredWidth, child.MeasuredHeight); }
private void DoDraw(Canvas canvas) { // Increment / reset size += delta; if (size > 250) { delta = -1; } else if (size < 30) { delta = 1; } // Set background color canvas.DrawColor(Color.BLUE); var paint = new Paint(); paint.TextAlign =(Paint.Align.CENTER); // Draw some lines canvas.DrawLine(mX, mY, mY + 33, mX + 100, paint); paint.Color =(Color.RED); paint.StrokeWidth = (10); canvas.DrawLine(87, 0, 75, 100, paint); paint.Color =(Color.GREEN); paint.StrokeWidth = (5); for (int y = 30, alpha = 128; alpha > 2; alpha >>= 1, y += 10) { paint.Alpha = (alpha); canvas.DrawLine(mY, y, mY + 100, y, paint); } // Draw a red rectangle paint.Color =(Color.RED); var rect = new Rect(); rect.Set(size + 120, 130, size + 156, 156); canvas.DrawRect(rect, paint); // Draw a circle paint.Color =(Color.ParseColor("#ffd700")); canvas.DrawCircle(size * 2, 220, 30, paint); //faster circle // Draw red'ish rectangle paint.Color =(Color.Rgb(128, 20, 20)); canvas.DrawRect(size, 67, 68, 45, paint); // Draw green circle paint.Color =(Color.GREEN); canvas.DrawCircle(size, 140.0f - size / 3, 45.0f, paint); //move circle across screen paint.Color =(Color.RED); canvas.DrawText("Dot42", size, 140.0f - size / 3, paint); // Draw magenta circle paint.Color =(Color.MAGENTA); canvas.DrawCircle(mX, mY, size / 4.0f, paint); //move circle down screen paint.Color =(Color.GREEN); canvas.DrawText("is", mX, mY, paint); // Draw yellow rectangle paint.Alpha = (64); paint.Color =(Color.YELLOW); canvas.DrawRect(size, size, size + 45, size + 45, paint); // Draw text on rectangle paint.Alpha = (255); paint.Color =(Color.DKGRAY); canvas.DrawText("fun!", size + 45 / 2, size + 45 / 2, paint); }
public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { outRect.Set(0, 0, 0, divider.IntrinsicHeight); }
protected override void OnDraw(Canvas ca) { if (fullImage == null || shouldUpdate) { fullImage = Bitmap.CreateBitmap (Width, Height, Bitmap.Config.Argb8888); Canvas canvas = new Canvas(fullImage); canvas.DrawColor(Color.Transparent); //NinePatchDrawable popup = (NinePatchDrawable)this.Resources.GetDrawable (Android.Resource.Drawable.AlertDarkFrame); float maxValue = 0; float padding = 7; int selectPadding = 4; float bottomPadding = 40; float usableHeight; if (showBarText) { this.p.TextSize = 40; this.p.GetTextBounds(unit, 0, 1, r3); usableHeight = Height - bottomPadding - Math.Abs(r3.Top - r3.Bottom) - 26; } else { usableHeight = Height - bottomPadding; } p.Color = Color.Black; p.StrokeWidth = 2; p.Alpha = 50; p.AntiAlias = true; canvas.DrawLine(0, Height - bottomPadding + 10, Width, Height - bottomPadding + 10, p); float barWidth = (Width - (padding * 2) * points.Count) / points.Count; foreach (Bar po in points) { maxValue += po.getValue(); } r = new Rect(); path.Reset(); int count = 0; foreach (Bar po in points) { if(po.getStackedBar()){ List<BarStackSegment> values = new List<BarStackSegment>(po.getStackedValues()); int prevValue = 0; foreach (BarStackSegment value in values) { value.Value += prevValue; prevValue += value.Value; } //Collections.Reverse(values); foreach (BarStackSegment value in values) { r.Set((int) ((padding * 2) * count + padding + barWidth * count), (int) ((Height - bottomPadding - (usableHeight * (value.Value / maxValue)))), (int) ((padding * 2) * count + padding + barWidth * (count + 1)), (int) ((Height - bottomPadding))); path.AddRect(new RectF(r.Left - selectPadding, r.Top - selectPadding, r.Right + selectPadding, r.Bottom + selectPadding), Path.Direction.Cw); po.setPath(path); po.setRegion(new Region(r.Left - selectPadding, r.Top - selectPadding, r.Right + selectPadding, r.Bottom + selectPadding)); this.p.Color = value.Color; this.p.Alpha = 255; canvas.DrawRect (r, this.p); } }else { r.Set((int) ((padding * 2) * count + padding + barWidth * count), (int) (Height - bottomPadding - (usableHeight * (po.getValue() / maxValue))), (int) ((padding * 2) * count + padding + barWidth * (count + 1)), (int) (Height - bottomPadding)); path.AddRect(new RectF(r.Left - selectPadding, r.Top - selectPadding, r.Right + selectPadding, r.Bottom + selectPadding), Path.Direction.Cw); po.setPath(path); po.setRegion(new Region(r.Left - selectPadding, r.Top - selectPadding, r.Right + selectPadding, r.Bottom + selectPadding)); this.p.Color = po.getColor (); this.p.Alpha=255; canvas.DrawRect(r, this.p); } this.p.TextSize = 20; canvas.DrawText(po.getName(), (int) (((r.Left + r.Right) / 2) - (this.p.MeasureText(po.getName()) / 2)), Height - 5, this.p); if (showBarText) { this.p.TextSize=40; this.p.Color=Color.White; this.p.GetTextBounds (unit + po.getValue (), 0, 1, r2); // if (popup != null) // popup.SetBounds((int) (((r.Left + r.Right) / 2) - (this.p.MeasureText(unit + po.getValue()) / 2)) - 14, r.Top + (r2.Top - r2.Bottom) - 26, (int) (((r.Left + r.Right) / 2) + (this.p.MeasureText(unit + po.getValue()) / 2)) + 14, r.Top); // popup.Draw(canvas); if (isAppended()) canvas.DrawText(po.getValue() + unit, (int) (((r.Left + r.Right) / 2) - (this.p.MeasureText(unit + po.getValue()) / 2)), r.Top - 20, this.p); else canvas.DrawText(unit + po.getValue(), (int) (((r.Left + r.Right) / 2) - (this.p.MeasureText(unit + po.getValue()) / 2)), r.Top - 20, this.p); } if (indexSelected == count && listener != null) { this.p.Color = Color.ParseColor ("#33B5E5"); this.p.Alpha = 100; canvas.DrawPath (po.getPath (), this.p); this.p.Alpha = 255; } count++; } shouldUpdate = false; } ca.DrawBitmap(fullImage, 0, 0, null); }
public void OnLayout(bool changed, int left, int top, int right, int bottom) { if (_disposed || _renderer == null || _element == null) return; AButton view = View; if (view == null) return; Drawable drawable = null; Drawable[] drawables = TextViewCompat.GetCompoundDrawablesRelative(view); if (drawables != null) { foreach (var compoundDrawable in drawables) { if (compoundDrawable != null) { drawable = compoundDrawable; break; } } } if (drawable != null) { int iconWidth = drawable.IntrinsicWidth; drawable.CopyBounds(_drawableBounds); // Center the drawable in the button if there is no text. // We do not need to undo this as when we get some text, the drawable recreated if (string.IsNullOrEmpty(_element.Text)) { var newLeft = (right - left - iconWidth) / 2 - view.PaddingLeft; _drawableBounds.Set(newLeft, _drawableBounds.Top, newLeft + iconWidth, _drawableBounds.Bottom); drawable.Bounds = _drawableBounds; } else { if (_alignIconWithText && _element.ContentLayout.IsHorizontal()) { var buttonText = view.TextFormatted; // if text is transformed, add that transformation to to ensure correct calculation of icon padding if (view.TransformationMethod != null) buttonText = view.TransformationMethod.GetTransformationFormatted(buttonText, view); var measuredTextWidth = view.Paint.MeasureText(buttonText, 0, buttonText.Length()); var textWidth = Math.Min((int)measuredTextWidth, view.Layout.Width); var contentsWidth = ViewCompat.GetPaddingStart(view) + iconWidth + view.CompoundDrawablePadding + textWidth + ViewCompat.GetPaddingEnd(view); var newLeft = (view.MeasuredWidth - contentsWidth) / 2; if (_element.ContentLayout.Position == Button.ButtonContentLayout.ImagePosition.Right) newLeft = -newLeft; if (ViewCompat.GetLayoutDirection(view) == ViewCompat.LayoutDirectionRtl) newLeft = -newLeft; _drawableBounds.Set(newLeft, _drawableBounds.Top, newLeft + iconWidth, _drawableBounds.Bottom); drawable.Bounds = _drawableBounds; } } } _hasLayoutOccurred = true; }
public override IViewParent InvalidateChildInParent(int[] location, Rect dirty) { location[0] = Left; location[1] = Top; dirty.Set (0, 0, Width, Height); return Parent; }