xamarin/Xamarin.Forms

[Bug] VerticalTextAlignment.Center of Entry on UWP is not working as expected (regression)

Aberta

#8.835 aberto em 10 de dez. de 2019

 (2 comentários) (0 reação) (0 responsável)C# (1.926 forks)batch import
e/6 :clock6:help wantedinactivep/UWPt/bug :bug:up-for-grabs

Métricas do repositório

Stars
 (5.644 estrelas)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

Description

This appears to be a regression of a bug that was fixed long ago (see https://xamarin.github.io/bugzilla-archives/55/55397/bug.html )

When using VerticalTextAlignment with Entry on UWP, the vertical alignment is not as expected. I have added some red lines to the attached screenshot, to highlight some of the issues.

The top Entry with red lines is using the Micro FontSize. In this case, it is clear that the caret (as well as the Text) is not vertically centered within the Entry, both being closer to the top of the Entry than the bottom of the Entry.

The bottom Entry with red lines is using the Header FontSize. In this case, it is clear that the Text is not vertically centered within the Entry (the distance between the top of the f and the top of the Entry is much greater than between the bottom of the g and the bottom of the Entry).

Steps to Reproduce

Include the following code in the Children of a Layout on a Page (I used a StackLayout, but it doesn't have to be):

                    new Entry
                    {
                        Placeholder = "Micro - fg",
                        FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Entry)),
                        HorizontalTextAlignment = TextAlignment.Center,
                        VerticalTextAlignment = TextAlignment.Center,
                        TabIndex = 3,
                        IsTabStop = true,
                        ClearButtonVisibility = ClearButtonVisibility.Never,
                        Text = "dgfjhpkqlyt",
                    },
                    new Entry
                    {
                        Placeholder = "Small - fg",
                        FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Entry)),
                        HorizontalTextAlignment = TextAlignment.Center,
                        VerticalTextAlignment = TextAlignment.Center,
                        TabIndex = 4,
                        IsTabStop = true,
                        ClearButtonVisibility = ClearButtonVisibility.Never,
                        Text = "dgfjhpkqlyt",
                    },
                    new Entry
                    {
                        Placeholder = "Medium - fg",
                        FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Entry)),
                        HorizontalTextAlignment = TextAlignment.Center,
                        VerticalTextAlignment = TextAlignment.Center,
                        TabIndex = 5,
                        IsTabStop = true,
                    },
                    new Entry
                    {
                        Placeholder = "Large - fg",
                        FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Entry)),
                        HorizontalTextAlignment = TextAlignment.Center,
                        VerticalTextAlignment = TextAlignment.Center,
                        TabIndex = 6,
                        IsTabStop = true,
                        ClearButtonVisibility = ClearButtonVisibility.Never,
                        Text = "dgfjhpkqlyt",
                    },
                    new Entry
                    {
                        Placeholder = "Default - fg",
                        FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Entry)),
                        HorizontalTextAlignment = TextAlignment.Center,
                        VerticalTextAlignment = TextAlignment.Center,
                        TabIndex = 7,
                        IsTabStop = true,
                        ClearButtonVisibility = ClearButtonVisibility.Never,
                        Text = "dgfjhpkqlyt",
                    },
                    new Entry
                    {
                        Placeholder = "Header - fg",
                        FontSize = Device.GetNamedSize(NamedSize.Header, typeof(Entry)),
                        HorizontalTextAlignment = TextAlignment.Center,
                        VerticalTextAlignment = TextAlignment.Center,
                        TabIndex = 8,
                        IsTabStop = true,
                        ClearButtonVisibility = ClearButtonVisibility.Never,
                        Text = "dgfjhpkqlyt",
                    },
                    new Entry
                    {
                        Placeholder = "Title - fg",
                        FontSize = Device.GetNamedSize(NamedSize.Title, typeof(Entry)),
                        HorizontalTextAlignment = TextAlignment.Center,
                        VerticalTextAlignment = TextAlignment.Center,
                        TabIndex = 9,
                        IsTabStop = true,
                        ClearButtonVisibility = ClearButtonVisibility.Never,
                        Text = "dgfjhpkqlyt",
                    },
                    new Entry
                    {
                        Placeholder = "Subtitle - fg",
                        FontSize = Device.GetNamedSize(NamedSize.Subtitle, typeof(Entry)),
                        HorizontalTextAlignment = TextAlignment.Center,
                        VerticalTextAlignment = TextAlignment.Center,
                        TabIndex = 10,
                        IsTabStop = true,
                        ClearButtonVisibility = ClearButtonVisibility.Never,
                        Text = "dgfjhpkqlyt",
                    },
                    new Entry
                    {
                        Placeholder = "Body - fg",
                        FontSize = Device.GetNamedSize(NamedSize.Body, typeof(Entry)),
                        HorizontalTextAlignment = TextAlignment.Center,
                        VerticalTextAlignment = TextAlignment.Center,
                        TabIndex = 11,
                        IsTabStop = true,
                        ClearButtonVisibility = ClearButtonVisibility.Never,
                        Text = "dgfjhpkqlyt",
                    },
                    new Entry
                    {
                        Placeholder = "Caption - fg",
                        FontSize = Device.GetNamedSize(NamedSize.Caption, typeof(Entry)),
                        HorizontalTextAlignment = TextAlignment.Center,
                        VerticalTextAlignment = TextAlignment.Center,
                        TabIndex = 12,
                        IsTabStop = true,
                        ClearButtonVisibility = ClearButtonVisibility.Never,
                        Text = "dgfjhpkqlyt",
                    },

Expected Behavior

The Text and PlaceholderText should be vertically centered in each Entry. The caret should be vertically centered in whichever Entry has focus.

Actual Behavior

See description above.

Basic Information

  • Version with issue: 4.3.0.991211
  • IDE: VS2019
  • Platform Target Frameworks:
    • UWP: 18362

Screenshots

Guia do colaborador