我正在尝试设置一个XAML表单定义,它显示一个WebView,但它在右下角有一个浮动操作按钮。
如果我使用AbsoluteLayout,FAB将正确地显示在WebView上。但是,由于Webview的高度/WidthRequest,它是以完整的大小显示的--文本从右侧消失,没有包装,所以页面不会滚动。
<ContentPage ...snip... Title="Document">
<StackLayout Padding="5,5,5,5" HorizontalOptions="FillAndExpand" Orientation="Vertical">
<WebView x:Name="webViewDocument" WidthRequest="1000" HeightRequest="1000" />
<Label Text="{Binding UpdatedWhen, StringFormat='Last Updated: {0:dd MMM yyyy HH:mm}'}"
VerticalTextAlignment="Center" HorizontalTextAlignment="End" FontSize="Small" />
<customControls:ImageButton x:Name="fab"
Source="{markupExtensions:PlatformImage SourceImage='IconFAB'}"
Command="{Binding AddCommand}"
AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds="0.95,0.975,-1,-1"
Margin="10" />
</StackLayout>
</ContentPage>如果我使用StackLayout,WebView大小和滚动是正确的,但是FAB在屏幕底部占据了一个完整的宽度条,并且文本不会出现在它后面-- WebView会停在它上面。
过去一个半小时,我一直在尝试每一个嵌套布局的组合来解决这个问题,但却做不到--一些优秀的布局专家能告诉我如何解决这个问题吗?
谢谢
发布于 2018-04-11 18:51:51
使用Grid,不要指示行或列。
就像这样:
<Grid Padding="5,5,5,5"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">
<WebView x:Name="webViewDocument"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand" />
<Label Text="{Binding UpdatedWhen, StringFormat='Last Updated: {0:dd MMM yyyy HH:mm}'}"
VerticalOptions="End"
HorizontalOptions="Center"
HorizontalTextAlignment="End"
FontSize="Small" />
<customControls:ImageButton x:Name="fab"
Source="{markupExtensions:PlatformImage SourceImage='IconFAB'}"
Command="{Binding AddCommand}"
VerticalOptions="End"
HorizontalOptions="End"
Margin="10" />
</Grid>这应该对你有用。
https://stackoverflow.com/questions/49779290
复制相似问题