locked
[Xamarin Forms 2.5] There is a space in the button. What is it? RRS feed

  • Question

  • User141776 posted

    Hi guys, what was changed in the previous versions in a button?

    Here is XAML:

        <StackLayout Orientation="Horizontal"
                           HorizontalOptions="FillAndExpand"
                           Margin="5, 0, 5, 0"
                           Spacing="0">
                <Button Text="TEST"
                        Command="{BindingCommand}"
                        IsEnabled="{Binding IsBusy, Converter={c:NegateBooleanConverter}}"
                        HorizontalOptions="FillAndExpand" />
              </StackLayout>
    

    This is space exists in XF2.5sr1

    The same button and the space does not exist on previous XF2.4.0.282 version

    The biggest issue here is the space has a different size in iOS, UWP and Android!

    Monday, November 27, 2017 4:03 PM

Answers

  • User141776 posted

    Yes, it helps, thank you

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, November 28, 2017 7:52 AM

All replies

  • User134959 posted

    That issue has already happened before (I don't rembember exactly which version of Xamarin.Forms). What you can do to fix that is to implement an empty ButtonRenderer for Android (I can't explain how, but it works).

        public class MarginlessButtonRenderer : ButtonRenderer
            {
                protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Button> e)
                {
                    base.OnElementChanged(e);
                }
            }
    
    Monday, November 27, 2017 6:23 PM
  • User134959 posted

    Ps: It only works if you set a background color for Button*

    Monday, November 27, 2017 6:25 PM
  • User141776 posted

    Yes, it helps, thank you

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, November 28, 2017 7:52 AM