xamarin/Xamarin.Forms

[Bug] Custom Gradient Renderer blows Canvas size on Android

オープン

#7,104 opened on 2019/08/08

 (5 件のコメント) (0 件のリアクション) (0 人の担当者)C# (1,926 件のフォーク)batch import
a/customrenderera/layoute/8 :clock8:excellent-reporthelp wantedp/Androidt/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

Description

Creating a custom Frame Renderer to display a Gradient as the background, the gradient expands past the Canvas size on Android using Xamarin.Forms version 4.0.0.540366 or above.

I am using a custom renderer to create Frames with gradient backgrounds, (following examples found elsewhere). The custom renderer works fine if using the Xamaring.Forms version 4.0.0.497661 or older, but upgrading the package to version 4.0.0.540366 or newer, the gradient background expands past the size of the Frame and over other elements on screen.

I had the same problem with version 4.0.0.497661 and I managed to fix the problem by surrounding my custom renderer with a Frame element, which would constrain the background size of the Canvas to the parent Frame, but even this "fix" is not working anymore on newer versions of the package.

For Android testing I am using a Google Pixel 2 running API 28. Some tests on the Android Emulator does NOT reproduce the error.

Steps to Reproduce

The followings steps illustrates how to reproduce using the attached sample code. The sample code should be using the version 4.0.0.540366, so the first execution of the application on Android should show the page working as expected, upgrading the package to version 4.0.0.540366 will show the problem on rendering.

  1. Create a new Renderer for the Shared Library with platform specific implementations on both iOS and Android
  2. Add a new GradientFrame to XAML with elements inside. Set the required colours for the gradient.
  3. Change Nuget package of Xamaring.Forms between 4.0.0.497661 and 4.0.0.540366

Expected Behavior

The Title would have a Gradient background; The Sub-Title frame would have a Gradient background;

Actual Behavior

The Sub-Title Gradient Frame background expands past the containing border and is displayed over other elements on the page

Basic Information

  • Version with issue: 4.0.0.540366 and above
  • Last known good version: 4.0.0.497661
  • IDE: Visual Studio For Mac 2019
  • Platform Target Frameworks:
    • Android: API 28
  • Nuget Packages:
    • Xamaring.Essentials

Screenshots

  • Android

    • Working sample using Version 4.0.0.497661
    • Version with problem using Version 4.0.0.540366
    • No workaround on version 4.0.0.497661 - No Surrounded Frame
  • iOS - Version Using 4.0.0.540366

Reproduction Link

Xamarin.Forms - Gradient Renderer.zip

コントリビューターガイド