Skip to content

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

Draft
Copilot wants to merge 5 commits into
mainfrom
copilot/fix-grid-row-0-display
Draft

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

Conversation

Copilot AI commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

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
michaelstonis and others added 3 commits May 28, 2026 13:21
The BackgroundColor setter's Color.Argb(...) call was missing its Blue
argument and closing paren, leaving the ternary ':' where the 4th
argument belongs. This caused CS1525/CS1026 and made the library
unbuildable for net9.0-android. Complete the ARGB call and fix the
indentation of the trailing SetBackgroundColor/Invalidate statements.

No behavior change beyond making the project compile.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds a dedicated, toggle-driven repro harness (LayoutReproPage) for
validating layering issues such as GitHub issue #8 (content overlapping
a PdfView hidden unless BackgroundColor is set; scroll-time flicker).

Controls:
  - Layout: Overlay (header shares the PdfView cell — the #8 repro) vs
    Stacked (separate row — the control case).
  - Background: cycle (unset) -> Transparent -> White to demonstrate the
    default-transparent behavior added in 328b7aa.
  - Header ZIndex: toggle the commenter's flicker workaround.

Wires both pages into a Shell flyout and makes Repro Lab the landing page.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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