Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Frame doesn't obey HeightRequest

Can you guys please explain why the Frame doesn't respect the HeightRequest or WidthRequest?

Using those properties in other controls it works as expected.

For example, in this XAML I'm using a Frame and a BoxView:

<StackLayout Orientation="Horizontal"
             HorizontalOptions="CenterAndExpand"
             Padding="10">
    <Frame VerticalOptions="Center"
           HeightRequest="5"
           WidthRequest="5"
           BackgroundColor="Red"/>
    <BoxView VerticalOptions="Center"
             HeightRequest="5"
             WidthRequest="5"
             Color="Blue"/>
</StackLayout>

And the result is:

xaml sample

There is a big difference between the Frame's size and box's size, but it shouldn't have.

like image 389
Diego Rafael Souza Avatar asked Feb 12 '18 13:02

Diego Rafael Souza


1 Answers

Frame has a default padding of 20. Set Padding="0".

See the remarks here: https://developer.xamarin.com/api/type/Xamarin.Forms.Frame/

like image 161
sme Avatar answered Oct 22 '22 09:10

sme