Skip to content

Ensure Android PdfView defaults to transparent background when BackgroundColor is unset#9

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-grid-row-0-display
Draft

Ensure Android PdfView defaults to transparent background when BackgroundColor is unset#9
Copilot wants to merge 2 commits intomainfrom
copilot/fix-grid-row-0-display

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 22, 2026

When PdfView is placed in a Grid on Android, leaving BackgroundColor unset could cause row 0 content to be visually obscured. Explicitly setting BackgroundColor="Transparent" worked around it; this change makes that behavior the default.

  • Android native background initialization

    • Set the underlying PDFView background to transparent at construction time so unset MAUI background does not inherit problematic native defaults.
  • Consistent null-background mapping

    • Updated BackgroundColor mapping to always apply a native color:
      • explicit MAUI color → mapped ARGB
      • null MAUI background → Android.Graphics.Color.Transparent
  • Behavioral impact

    • Preserves explicit background behavior.
    • Removes the need for consumers to manually set BackgroundColor="Transparent" to avoid Grid row 0 visibility issues.
public PdfViewAndroid(Context context)
{
    _pdfView = new PDFView(context, null);
    _pdfView.SetBackgroundColor(global::Android.Graphics.Color.Transparent);
}

public Color? BackgroundColor
{
    get => _backgroundColor;
    set
    {
        _backgroundColor = value;
        var androidColor = value != null
            ? global::Android.Graphics.Color.Argb(
                (int)(value.Alpha * 255),
                (int)(value.Red * 255),
                (int)(value.Green * 255),
                (int)(value.Blue * 255))
            : global::Android.Graphics.Color.Transparent;
        _pdfView.SetBackgroundColor(androidColor);
    }
}

Copilot AI changed the title [WIP] Fix row 0 display issue when BackgroundColor is not set Ensure Android PdfView defaults to transparent background when BackgroundColor is unset Apr 22, 2026
Copilot AI requested a review from michaelstonis April 22, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

If used with a Grid, row 0 is not shown if BackgroundColor property is not set

2 participants