2014-06-23 17 views
8

Mam stacklayout zakodowanej tak:wypełnić cały ekran z stacklayout

StackLayout mainStackLayOut = new StackLayout{ 
    BackgroundColor = Color.Blue, 
    //VerticalOptions = LayoutOptions.FillAndExpand, 
    //WidthRequest = width, 
    HorizontalOptions = LayoutOptions.FillAndExpand, 
    Orientation = StackOrientation.Vertical 
}; 

ale chcę mój stacklayout aby wypełnić całą szerokość i wysokość ekranu, także mam przyciski drzewo Dodane tak:

StackLayout buttonsStackLayOut = new StackLayout 
{ 
    BackgroundColor = Color.White, 
    //VerticalOptions = LayoutOptions.Fill, 
    HorizontalOptions = LayoutOptions.Fill, 
    Orientation = StackOrientation.Horizontal, 
    Spacing = 0 
}; 
mainStackLayOut.Children.Add(buttonsStackLayOut); 


Image doctorImage = new Image 
{ 
    WidthRequest = width/3, 
    HeightRequest = 50, 
    BackgroundColor = Color.Gray, 
    Source = ImageSource.FromFile ("about.png") 
}; 
buttonsStackLayOut.Children.Add(doctorImage); 

enter image description here

Jak mogę wypełnić cały Rozmiar ekranu?

+0

w czym problem? czarne linie po lewej i prawej? –

+0

Tak, dokładnie to jest problem –

+2

Czy próbowałeś jawnie ustawić wypełnienie = "0" –

Odpowiedz

8

W najprostszej formie udało mi się osiągnąć to, czego potrzebujesz.

Ustawiam zawartość ekranu na układ głównego stosu.

 var mainStackLayout = new StackLayout { BackgroundColor = Color.Blue}; 
     var buttonsStackLayout = new StackLayout { BackgroundColor = Color.White, Orientation = StackOrientation.Horizontal , Spacing = 0 }; 

     Image about = new Image { HeightRequest = 50, Source = ImageSource.FromFile("about.jpg") }; 
     Image twitter = new Image { HeightRequest = 50, Source = ImageSource.FromFile("twitter.jpg") }; 
     Image refresh = new Image { HeightRequest = 50, Source = ImageSource.FromFile("refresh.jpg") }; 

     buttonsStackLayout.Children.Add(about); 
     buttonsStackLayout.Children.Add(twitter); 
     buttonsStackLayout.Children.Add(refresh); 

     mainStackLayout.Children.Add(buttonsStackLayout); 
     this.Content = mainStackLayout; 

enter image description here

Powiązane problemy