xamarin/Xamarin.Forms

Behavior of Page with both BackgroundColor and BackgroundImage set

Open

#5,067 opened on Jan 26, 2019

 (6 comments) (0 reactions) (0 assignees)C# (1,926 forks)batch import
breakinge/2 :clock2:good first issuehelp wantedinactivep/Androidt/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Description

While working on PR #5066 for #5057 I noticed a potential issue when Page has both BackgroundColor and BackgroundImage set.

Steps to Reproduce

  1. Set BackgroundColor="Red"

  2. Set BackgroundImage="someimage.jpg" On all platforms, image is shown.

  3. Set BackgroundColor=Color.Default iOS and UWP: image stays. This is because BackgroundImage is handled first before BackgroundColor, image takes priority over color. Android: image is gone, white background appears. Android doesn't handle the priority.

  4. Set BackgroundColor="Red" iOS and UWP: image stays Android: background is Red

  5. Set BackgroundImage=null iOS and UWP: Yay, background is finally red again! Android: Background is now white!

I attached a video with the described steps. pagebkgnd.zip

Expected Behavior

I'm not sure, I haven't been able to find it mentioned in the documentation portal what's expected to happen when both properties are set.

My proposal: like on iOS and UWP, have BackgroundImage take priority over BackgroundColor. When clearing the BackgroundImage, the Page should look with a background color of BackgroundColor.

Please let me know how you'd like this implemented, and I'd like to work on it

Actual Behavior

See it described in the steps above.

Basic Information

Latest code from my PR #5066.

Contributor guide