xamarin/Xamarin.Forms

Border issue and inconsistency

开放

#4,853 创建于 2018年12月24日

 (6 条评论) (0 个反应) (0 位负责人)C# (1,926 个派生)batch import
e/6 :clock6:help wantedinactivep/Androidp/UWPp/iOS 🍎t/bug :bug:up-for-grabs

仓库指标

星标
 (5,644 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Description

The way border is computed, drawn and the way it accounts for Button's size is not consistent across platforms.

The following XAML:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="App36.MainPage">
    <StackLayout VerticalOptions="Center"
                 Padding="20">
        <Button Text="Button" 
                BorderWidth="40"
                BorderColor="Green"
                ContentLayout="Right, 20"
                Padding="0">
            <Button.Image>
                <OnPlatform x:TypeArguments="FileImageSource">
                    <On Platform="iOS" Value="icon.png" />
                    <On Platform="Android" Value="icon.png" />
                    <On Platform="UWP" Value="Assets/icon.png" />
                </OnPlatform>
            </Button.Image>
        </Button>
    </StackLayout>
</ContentPage>

renders on Android, iOS and UWP like this:

image

On Android and iOS, the border is drawn behind/above the button's content (image in this case), and it does not influence the button size. On UWP, the border is drawn around the button's content, and the button size accounts it, the button size is bigger than without the border. The button's content size is preserved. (Note that on UWP, although I have set Padding = 0, there's still some padding, but that's a separate issue not related to this ticket).

Steps to Reproduce

See XAML above or attached demo app.

Expected Behavior

In my opinion, I think UWP's behavior is the correct one. A "border" should be exactly that, it should be around the view's content, it should not be drawn over the content. As a consequence, the view's size should increase to take the border width into account. I think this should be addressed before adding border to more controls.

Padding works correctly, it increases the size of the view.

Actual Behavior

See description and picture above.

Basic Information

  • Version with issue: Latest release (3.4.0.1008975)

  • Last known good version: ?

  • IDE:

  • Platform Target Frameworks:

    • iOS:
    • Android:
    • UWP:
  • Android Support Library Version:

  • Nuget Packages:

  • Affected Devices:

Reproduction Link

App36.zip

贡献者指南