2016-08-02 3 views
1

가로로 장치가있을 때 stacklayout이 모든 화면 너비를 차지하도록하려면 어떻게해야합니까? 여기 in Landscape mode stacklayout does not fill parentXamarin 양식 stacklayout 가로로 화면 채우기

내 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> 
나는 풍경 화면 폭을 stacklayout 원하는

; 그러나 초상에서만 일은이다.

답변

2

컨트롤이 AbsoluteLayout 인 직접 자식 인 경우 HorizontalOptionsVerticalOptions은 아무 효과가 없습니다. 모든 사이징은 AbsoluteLayout.LayoutBoundsAbsoluteLayout.LayoutFlags에서 설정해야합니다. 그래서 StackLayout이로 변경 시도 :

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

그런 다음 당신은 또한 당신의 ListView.HorizontalOptionsFillAndExpand로 설정하지만, 첫 번째없이 시도해야 할 수 있습니다.

+0

지금 작동 중입니다. :) 정말로 명확한 대답입니다. 고마워요 –

+0

@EricOcampo 전혀 문제 없습니다. 다행이 당신을 위해 일 했어. – hvaughan3