Forum Xamarin Xamarin.Android

What the heck happened with android buttons?

Just upgraded, and voila. Margin appeared on android buttons, looks like it is aligned by entry's write line, not whole box.

<StackLayout Margin="30">
    <Entry HorizontalOptions="FillAndExpand" BackgroundColor="White"/>
    <Entry HorizontalOptions="FillAndExpand" BackgroundColor="white"/>
    <Button HorizontalOptions="FillAndExpand" Text="Booo" BackgroundColor="PaleVioletRed"/>
</StackLayout>

How to turn it back?

Answers

  • DhruvKanojiaDhruvKanojia USMember ✭✭

    Try this :

    <StackLayout Margin="30">
        <Entry HorizontalOptions="FillAndExpand" BackgroundColor="White"/>
        <Entry HorizontalOptions="FillAndExpand" BackgroundColor="white"/>
        <Button HorizontalOptions="FillAndExpand" Margin="0" Text="Booo" BackgroundColor="PaleVioletRed"/>
    </StackLayout>
    
  • DhruvKanojiaDhruvKanojia USMember ✭✭

    Or you can try a custom renderer, as mentioned here

  • SuperDev.2956SuperDev.2956 USMember ✭✭

    Actually, it got to be harder:

    <Setter Property="Margin">
        <Setter.Value>
            <OnPlatform x:TypeArguments="Thickness" Android="-6" iOS="0" />
        </Setter.Value>
    </Setter>
    

    This somehow works, but I want to know what Xamarin/Google actually did to extra margins happen and undo this. Any Xamarin guy here?

  • yawnoyawno USMember ✭✭

    where did you get the -6 from? for me in order to fix it I used Margin="-4,-1" and then it looks much better

Sign In or Register to comment.