Reputation: 607
As we know in android we can use
android:width='wrap_content'
android:height='match_parent'
to set width or height of the views.
but, in xamarin forms we cannot use that.
so how can i set dynamic width or height for my xamarin forms component?
like match_parent
or wrap_content
in android
Upvotes: 2
Views: 10980
Reputation: 9356
In Xamarin.Forms you do the same using the LayoutOptions.
Let's say you have a Button which you want to grow horizontally (width) as its parent grow, you use:
var button4 = new Button {Text = "Click Me!", HorizontalOptions=LayoutOptions.FillAndExpand, VerticalOptions=LayoutOptions.Center};
LayoutOptions.FillAndExpand means it will take all the posible space available in its parent view (with some exceptions).
in XAML that'd be:
<Button Text="Click Me!"
HorizontalOptions="FillAndExpand"
VerticalOptions="Center" />
Suggest you to see the Getting Started of Xamarin Forms.
Upvotes: 9
Reputation: 361
Check out the options under HorizontalOptions and VerticalOptions. Sounds like FillAndExpand is what you are after.
Upvotes: 0