2017-08-08 102 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(重叠)。