robinmanuelthiel / flexbutton

Flexible button control for Xamarin.Forms
MIT License
240 stars 34 forks source link

Buttons don't center in Grid #88

Closed mike-rowley closed 3 years ago

mike-rowley commented 4 years ago

@robinmanuelthiel are you still maintaining this library?

Describe the bug Buttons do not center properly when inside a Grid with Auto Width Rows

To Reproduce Steps to reproduce the behavior: Replace your "WideButton" code in the Demo app with the following and the button will be left justified instead of centered.

<Grid x:Name="grd_Details" Padding="5" HorizontalOptions="FillAndExpand" VerticalOptions="StartAndExpand" BackgroundColor="Red">
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                    <flex:FlexButton
                        Grid.Column="0" Grid.Row="0"
                        x:Name="WideButton"
                        ClickedCommand="{Binding ButtonClickedCommand}"
                        IconOrientation="Right"
                        HorizontalOptions="Center"
                        Padding="0"
                        WidthRequest="300"
                        HeightRequest="76"
                        HasShadow="false"
                        CornerRadius="22"
                        Icon="lightbulb.png"
                        Text="Icon and Text"
                        BorderThickness="0,0,0,4"
                        BorderColor="#49516F"
                        HighlightBorderColor="#6279B8"
                        ForegroundColor="#ffffff"
                        HighlightForegroundColor="#49516F"
                        BackgroundColor="#6279B8"
                        HighlightBackgroundColor="#8EA4D2"/>
            </Grid>

Expected behavior The button should center as indicated in the HorizontalOptions even when inside a Grid.

Please complete the following information: Flexbutton 0.11 XamForms 4.5.0.725 Occurs on IOS and Android, unsure of UWP but would expect the same behaviour

robinmanuelthiel commented 3 years ago

There must be something wrong with your Grid configuration. I took your code and replaced flex:FlexButton with the regular Xamarin.Forms Button control. The result is the same, the button is not centered. So probably not a problem of the FlexButton but your Grid config.