2016-08-02 16 views
1

Wie kann ich Stacklayout nehmen alle Bildschirmbreite, wenn das Gerät in Landscape ist? in Landscape mode stacklayout does not fill parentXamarin Forms Stapellayout füllen Bildschirm auf Landschaft

hier ist meine 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" 
     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> 

ich auf Landschaft stacklayout nehmen Bildschirmbreite wollen; aber nur auf Porträt ist Arbeit.

Antwort

2

Wenn Steuerelemente direkte Kinder einer AbsoluteLayout Einstellung sind HorizontalOptions und VerticalOptions hat keine Wirkung. Alle Abmessungen müssen von AbsoluteLayout.LayoutBounds und AbsoluteLayout.LayoutFlags stammen. Also versuchen Sie Ihr StackLayout zu diesem Wechsel:

<AbsoluteLayout BackgroundColor="Silver" 
       HorizontalOptions="FillAndExpand"> 
    <StackLayout Orientation="Vertical" 
       BackgroundColor="Maroon" 
       AbsoluteLayout.LayoutBounds="0,0,1,1" 
       AbsoluteLayout.LayoutFlags="All"> 
    ... 

Dann müssen auch Sie können Ihre ListView.HorizontalOptions zu FillAndExpand setzen, sondern versuchen, ohne dass zuerst.

+0

arbeitet jetzt :) und wirklich klare Antwort. Vielen Dank –

+0

@EricOcampo Kein Problem. Froh, dass es für dich funktioniert hat. – hvaughan3