2017-08-08 56 views
0

是否可以在StackLayout前面放置一個帶有不透明度爲0.5和背景顏色的AbsoluteLayout,因此StackLayout內容在後臺仍可見。Xamarin.Forms - 絕對位置元素在其他內容前面的中心位置

事情是這樣的:

<StackLayout> 
    <StackLayout> 
     <Label Text="This text needs to be visible through the AbsoluteLayout"></Label> 
    </StackLayout> 
    <AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Opacity="0.5" BackgroundColor="Blue"> 
     <ActivityIndicator Color="White" IsRunning="true" VerticalOptions="Center" WidthRequest="20" HeightRequest="20" /> 
    </AbsoluteLayout> 
</StackLayout> 

除了這裏的AbsoluteLayout塊其他StackLayout,即使不透明度。我可以做任何事情來展示他們兩個,一個在另一個上?

+1

如果你想重疊,你應該使用網格或絕對佈局作爲最高級Contaiverer –

回答

1
<Grid> 
    <StackLayout> 
     <Label Text="This text needs to be visible through the AbsoluteLayout"></Label> 
    </StackLayout> 
    <AbsoluteLayout 
      HorizontalOptions="FillAndExpand" 
      VerticalOptions="FillAndExpand" 
      Opacity="0.5" 
      BackgroundColor="Blue" 
      InputTransparent="True"> 
     <ActivityIndicator Color="White" IsRunning="true" VerticalOptions="Center" WidthRequest="20" HeightRequest="20" /> 
    </AbsoluteLayout> 
</Grid> 


InputTransparent="True"將允許您通過點擊AbsoluteLayoutGrid將放置在StackLayoutAbsoluteLayout(重疊)。