webview - Xamarin Form WebView 高度作为 HTML 内容

标签 webview xamarin.forms

我有一个 WebView 加载一个带有 3 gif 的 html 页面。
我希望 WebView 变得和 HTML 内容一样大。这是可能的?
在 WebView 下,我在 Label 中显示了一些说明

   <Grid>
     <Grid>
       <Grid.RowDefinitions>
         <RowDefinition Height="auto"/>
         <RowDefinition Height="*"/>
         <RowDefinition Height="*"/>
       </Grid.RowDefinitions>
       <Grid Grid.Row="0" >
         <Grid.RowDefinitions>
           <RowDefinition/>
         </Grid.RowDefinitions>
         <Grid.ColumnDefinitions>
           <ColumnDefinition Width="*"/>
           <ColumnDefinition Width="*"/>
           <ColumnDefinition Width="*"/>
         </Grid.ColumnDefinitions>
         ...     
       </Grid>
       <Grid Grid.Row="1">
         <Grid.ColumnDefinitions>
           <ColumnDefinition Width="*"/>
         </Grid.ColumnDefinitions>
         <Grid.RowDefinitions>
           <RowDefinition Height="*"/>
         </Grid.RowDefinitions>
         <WebView x:Name="webw1" Grid.Row="0" Grid.Column="0"></WebView>
       </Grid>
       <Grid Grid.Row="2" >
         <Grid.RowDefinitions>
           <RowDefinition/>
         </Grid.RowDefinitions>
         <Grid.ColumnDefinitions>
           <ColumnDefinition Width="*"/>
         </Grid.ColumnDefinitions>
         <ScrollView Grid.Row="0" Grid.Column="0">
           <Label Text="LastExplanation" x:Name="lblLastExplanation" />
         </ScrollView>
       </Grid>
     </Grid>
   </Grid>
 </ContentPage>

public FinalCheck()
{
  InitializeComponent();
  webw1.Source = DependencyService.Get<IBaseUrl>().Get() + "instruction.html";
}

最佳答案

如果它不会改变,最简单的方法:<WebView x:Name="webw1" Grid.Row="0" Grid.Column="0" HeightRequest="xxx"></WebView>或者
在这种情况下,您可以创建自定义渲染器或创建一种与您的 html 页面进行通信以向您发送数据的方式
This如果它需要动态/交互式,可能会有所帮助。

关于webview - Xamarin Form WebView 高度作为 HTML 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37610827/

相关文章:

android - 如何在 Android Webview 中停止后台播放声音

c# - UWP Webview - 选项卡标题更改时触发事件(DocumentTitle)

android - Android Webview客户端证书和Http授权

c# - 'Microsoft.WindowsAzure.Storage.CloudStorageAccount' 的类型初始值设定项在 Xamarin.forms 中抛出异常错误

wcf - 如何在 Xamarin.forms PCL 中使用 WCF 服务?

android - 我无法在 webview 中整齐地加载网页

android - 在 webview 中检查输入

xamarin - 如何覆盖 iOS 的 Xamarin Forms TabbedPage 项目字体?

c# - 如何在 Xamarin Forms 中对列表进行分组?

ios - xamarin 表单中的钥匙串(keychain)配置