Xaml Xamarin表单堆叠布局填充屏幕在景观上
当设备处于横向时,我如何使用所有屏幕宽度? 这是我的Xaml:Xaml Xamarin表单堆叠布局填充屏幕在景观上,xaml,xamarin.forms,Xaml,Xamarin.forms,当设备处于横向时,我如何使用所有屏幕宽度? 这是我的Xaml: <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:ListView"
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:ListView"
x:Class="ListView.MainPage">
<ContentPage.Content>
<AbsoluteLayout BackgroundColor="Silver" HorizontalOptions="FillAndExpand">
<StackLayout Orientation="Vertical" HorizontalOptions="StartAndExpand" BackgroundColor="Maroon" VerticalOptions="StartAndExpand">
<Button Text="Reload data" Clicked="reloadData" x:Name="btnReload"/>
<ListView x:Name="listView">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout BackgroundColor="#eee" Orientation="Vertical">
<StackLayout Orientation="Horizontal" VerticalOptions="FillAndExpand">
<Image Source="{Binding Imagen}" HeightRequest="100" WidthRequest="120"/>
<Label Text="{Binding Titulo}" TextColor="Gray"/>
<Label Text="{Binding Fecha}" HorizontalOptions="EndAndExpand"/>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<ActivityIndicator BackgroundColor="Green" AbsoluteLayout.LayoutBounds=".5,.5,.2,.2" AbsoluteLayout.LayoutFlags="All" Color="Blue"
IsRunning="True" IsVisible="False" x:Name="overlay"/>
</AbsoluteLayout>
</ContentPage.Content>
我想在景观上调整屏幕宽度;但只有纵向才有效。当控件是
绝对布局的直接子控件时,设置水平选项
和垂直选项
无效。所有大小调整都必须来自设置AbsoluteLayout.LayoutBounds
和AbsoluteLayout.LayoutFlags
。因此,请尝试将您的StackLayout
更改为:
<AbsoluteLayout BackgroundColor="Silver"
HorizontalOptions="FillAndExpand">
<StackLayout Orientation="Vertical"
BackgroundColor="Maroon"
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All">
...
...
然后,您可能还需要将您的列表视图。HorizontalOptions
设置为FillAndExpand
,但请先尝试不使用该选项。正在工作:)并且答案非常清楚。谢谢,是这样much@EricOcampo没问题。很高兴它对你有用。