Skip to content

support customizable “aim” circle color (including alpha) in CameraView #164

@gsgou

Description

@gsgou

The “aim” indicator in CameraView (Android) is currently drawn with a fixed semi-transparent red paint and there’s no public API to override it. Apps that want the indicator to match their branding or accessibility guidelines must resort to fragile reflection hacks.

Expected Behavior
CameraView should expose a single bindable Color property for the aim indicator. The Color’s alpha channel determines opacity. For example, if you want a 50%-opaque blue circle, you would set the property to #800000FF.

Proposed Solution
Add a bindable property to CameraView:

public static readonly BindableProperty AimIndicatorColorProperty =
BindableProperty.Create(
nameof(AimIndicatorColor),
typeof(Color),
typeof(CameraView),
Colors.Red);

public Color AimIndicatorColor
{
get => (Color)GetValue(AimIndicatorColorProperty);
set => SetValue(AimIndicatorColorProperty, value);
}
In the Android renderer (CameraManager), replace the hard-coded paint:

// Old
new Paint
{
AntiAlias = true,
Color = Color.Red,
Alpha = 150
}
with:
var paint = new Paint { AntiAlias = true };
var platformColor = cameraView.AimIndicatorColor.ToPlatform();
paint.Color = platformColor;
Default the color to Colors.Red (with whatever default alpha that represents) so existing behavior remains unchanged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions