Migrated from https://bugzilla.xamarin.com/show_bug.cgi?id=27460
The original issue was that the color wouldn't appear unless padding was set. In my sample I don't see the color on Android at all. iOS renders as I'd expect.
The outline should be the color I've chosen, regardless of padding.
iOS renders as expected. Android outline isn't the chosen color, red.
CarView has no property to change the color of this border. You have to use a GradientDrawable in background. I can fix this bug if you wish.
When is this going to be released?
Still got this issue on Android
_FrameLayout = new Frame
{
Padding = 20,
Margin = 10,
BackgroundColor = Color.White,
Content = View,
HasShadow = true,
OutlineColor = Color.Red,
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.Center
};
@clovs What version of Xamarin Forms do you use?
Hello,
"Xamarin.Forms" version="2.5.0.280555" targetFramework="xamarinios10"
You can see on source code here: https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Renderers/FrameRenderer.cs
They use a BorderColor property from Frame Object,
But I got no one! @StephaneDelcroix
I just got an OutlineColor property. like describe in the doc:
https://developer.xamarin.com/api/type/Xamarin.Forms.Frame/
So I just redraw a stroke with OutlineColor property on the canvas with custom renderer:
Here my code:
```
public override void Draw(Canvas canvas)
{
base.Draw(canvas);
using (var strokePaint = new Paint())
using (var rect = new RectF(0, 0, canvas.Width, canvas.Height))
{
// stroke
strokePaint.SetStyle(Paint.Style.Stroke);
strokePaint.Color = Element.OutlineColor.ToAndroid();
strokePaint.StrokeWidth = 5;
canvas.DrawRoundRect(rect, Element.CornerRadius, Element.CornerRadius, strokePaint); // stroke
}
}
```
And Done!
but it still an issue, you can open it
Thanks,
Looking at https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Renderers/FrameRenderer.cs#L53 UpdateBackground()
and UpdateCornerRadius()
are being called but both do same thing:
void UpdateBackground()
{
this.SetBackground(new FrameDrawable(Element, Context.ToPixels));
}
void UpdateCornerRadius()
{
this.SetBackground(new FrameDrawable(Element, Context.ToPixels));
}
This ends up in calling SetBackground
and creating FrameDrawable twice.
This hurts performance and it should be necessary...
Another thing: in the FrameDrawable
ctor, I see subscription to the PropertyChanged
event of the Xamarin.Forms.Frame
instance. I can't see where it's unsubscribing from the event. I haven't though if it's really needed it or not though.
This issue is still very much a thing. Any updates?
This should be in 3.0.0
Hi! I'm still having issue with this on 3.2.0.839982 on Android - on iOS, Google Android simulators all ok - but on Android devices, Frame doesn't draw as expected. I use it to make a single pixel line - but on android devices it has only background. Fixed with a renderer
using Android.Content;
using Android.Graphics;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(SeparatorLine), typeof(SeparatorLineRenderer))]
namespace TechPortal.Droid.Controls
{
public class SeparatorLineRenderer : FrameRenderer
{
public SeparatorLineRenderer(Context context) : base(context)
{
}
public override void Draw(Canvas canvas)
{
base.Draw(canvas);
if (Element == null || Element.BorderColor.A <= 0)
{
return;
}
using (var paint = new Paint
{
AntiAlias = true
})
using (var path = new Path())
using (Path.Direction direction = Path.Direction.Cw)
using (Paint.Style style = Paint.Style.Stroke)
using (var rect = new RectF(0, 0, canvas.Width, canvas.Height))
{
var raduis = Android.App.Application.Context.ToPixels(Element.CornerRadius);
path.AddRoundRect(rect, raduis, raduis, direction);
//paint.StrokeWidth = Context.Resources.DisplayMetrics.Density * 2;
paint.SetStyle(style);
paint.Color = Element.BorderColor.ToAndroid();
canvas.DrawPath(path, paint);
}
}
}
}
This is still an issue. I'm using Xamarin.Form 4.0.0425677
@D4rkC1own187 can you create a new issue and try the latest?
Most helpful comment
When is this going to be released?