Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

189
Vistas
Oval Shape in Overlay View in Xamarin

I followed this Blog to add Overlay View on my Camera Preview.

In background, Camera Preview is opened, and on the top of it there is overlay outer rectangle (in Fuchsia color) and circle shape inside.

There are two shapes Circle & Heart. I want to add Oval.

I added Oval, but it didn't worked.

OverlayView.cs

public enum OverlayShape
    {
        Circle,
        Heart,
        Oval
    }
public static readonly BindableProperty ShapeProperty = BindableProperty.Create(
   propertyName: nameof(Shape),
   returnType: typeof(CameraOverlayShape),
   declaringType: typeof(CameraOverlayView),
   defaultValue: CameraOverlayShape.Oval,
   defaultBindingMode: BindingMode.TwoWay);

NativeOverlayView.cs

OverlayShape overlayShape = OverlayShape.Oval;

public OverlayShape Shape
{
    get { return overlayShape; }
    set
    {
        overlayShape = value;
        Redraw();

    }
}
Paint paint = new Paint(PaintFlags.AntiAlias)
{
    Color = OverlayBackgroundColor,
    Alpha = (int)(255 * Opacity)
};

RectF outerRectangle = new RectF(0, 0, width, height);

osCanvas.DrawRect(outerRectangle, paint);
switch (Shape)
{
    case OverlayShape.Oval:
        osCanvas.DrawOval(outerRectangle, paint);

        break;
    default:
    
    // Code
    
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The following code works on my side .

 case OverlayShape.Oval:
     shapeHeight = (float)(shapeHeight * 0.8);
     RectF rect = new RectF(width / 2- shapeWidth / 2, height / 2 - shapeHeight / 2, shapeWidth/2+ width/2 , shapeHeight/2+height/2);
     osCanvas.DrawOval(rect, paint);
     break;

enter image description here

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda