android - Xamarin Forms,Webview 在 Content 顶部留下空白
问题描述
当我使用 webview 时,它的顶部和底部有间隙,或者如果水平放置,它的侧面有间隙。如何让 webview 填满整个屏幕。
您可以在屏幕截图中看到蓝色区域是内容的背景颜色。为什么 webview 不从顶部开始?
我还添加了一个标签,该标签正确地位于屏幕顶部。
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="WorkingWithWebview.MyPage" >
<ContentPage.Content>
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Label Text="this is a label showing its not the nav bar" BackgroundColor="Red"></Label>
<WebView VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"
Source="https://www.google.com" WidthRequest="1000" HeightRequest="1000">
</WebView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
解决方案
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<ContentPage.Content>
<Grid HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<WebView HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<WebView.Source>
<HtmlWebViewSource Html="{Binding TermsAndConditions}"/>
</WebView.Source>
</WebView>
</Grid>
</ContentPage.Content>
这个设置对我很有效 =)
推荐阅读
- javascript - 如何在 puppeteer 中获取 div 中的文本
- r - 错误预测自动绘图:强制不是从色彩空间导出的对象
- macos - 使用 pip3 在 Mac 上安装 importlib 时出现问题
- java - 如果时差以秒为单位,则日期格式化程序不反映正确的字符串
- xslt - 通过 XPath 提取元素节点的值?
- python-3.x - 如何在 ConfigArgParse 中进行多行列表?
- lodash - 使用 lodash 查找嵌套对象
- spring - 在MongoDB,JAVA Spring中使用多列搜索
- c++ - C++ KOALA 图形库 - 理解语法以访问数据结构
- android - 如何像这样在Android中创建径向渐变