xamarin/Xamarin.Forms

[Bug] Scale/Translate works in different order between UWP and Android

Open

#7,257 opened on Aug 23, 2019

 (3 comments) (0 reactions) (0 assignees)C# (1,926 forks)batch import
a/layoute/3 :clock3:help wantedin-progressinactivep/UWPt/bug :bug:up-for-grabs

Repository metrics

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

Description

Description

When using the properties ScaleX/ScaleY and TranslationX/TranslationY on a view (in this case AbsoluteLayout) the position of the object is different between UWP and Android.

Steps to Reproduce

With an AbsoluteLayout as the current object being drawn on, run the following code :

Xamarin.Forms.AbsoluteLayout AL = new Xamarin.Forms.AbsoluteLayout () ; AL.BackgroundColor = Xamarin.Forms.Color.Green ; Xamarin.Forms.AbsoluteLayout.SetLayoutBounds (AL, new Xamarin.Forms.Rectangle (0, 0, 100, 100)); Xamarin.Forms.AbsoluteLayout.SetLayoutFlags (AL, Xamarin.Forms.AbsoluteLayoutFlags.None); AL.AnchorX = 0 ; AL.AnchorY = 0 ; AL.ScaleX = 0.5 ; AL.ScaleY = 0.5 ; AL.TranslationX = 100 ; AL.TranslationY = 100 ; Children.Add ( AL ) ;

Expected Behavior

The expected behaviour is that the position of the green square should be the same on Android and on UWP (iOS not tried). From the documentation it is not possible to tell which is expected, but they should both give the same result.

Actual Behavior

On UWP: the green square of side 50 is at (x,y) = (200,200). On Android: the green square of side 50 is at (x,y) = (100, 100).

Basic Information

On Android the translate is done with non scaled coordinates, on UWP you have to multiply the translation by the scale to get the same result.

  • Version with issue: Xamarin.Forms v4.2.0.709249

  • Last known good version:

  • IDE: Visual Studio 2019

  • Platform Target Frameworks:

    • Android: 8.1
    • UWP: 16299
  • Android Support Library Version: v28.0.0.1

  • Nuget Packages: standard Xamarin

  • Affected Devices:

Screenshots

Reproduction Link

Contributor guide