我的項目中有一個WebView。它可以有動態的html內容。現在我已經爲WebView提供了固定的寬度和高度,並且它可以滾動。但我想通過動態增加WebView的高度來移除滾動。竅門根據動態內容展開Xamarin Form WebView
有什麼辦法像創建自定義渲染器或什麼東西?
示例代碼
var webvw = new Webview();
var htmlSource = new HtmlWebViewSource();
htmlSource.Html = @"<html>" +
"<head>" +
"<style type=\"text/css\">" +
"@font-face {" +
"font-family: Roboto-Medium;" + fntsrc + "}" +
"html,body{margin:0px;}" +
"body {" +
"font-family: Roboto-Medium;" +
"font-size: 12px" +
"text-align: left;" +
"color: #acacac;" + "}" +
"body :first-child{" +
"font-family: Roboto-Medium;" +
"font-size: 12px" +
"font-weight: 300;" +
"line-height: 24px;" +
"text-align: left;" +
"color: #ffffff;" + "}" +
"</style>" +
"</head>" +
"<body style=\"background-color: transparent;\" >" +
dynamicContent + "</body>" + "</html>";
webvw.Source = htmlSource;
webvw.WidthRequest = 500;
webvw.HeightRequest = 500;
SatackLayout webContnet=new StackLayout{
VerticalOptions=LayoutOption.FillAndExpand,
Orientation=StackOrientation.Vertical
};
感謝您指出方向。我以其他方式做了。 – Atul
@Atul你是怎麼做到的?謝謝 – Rexxo
@Atul有沒有機會提供詳細信息? –