Web 视图在 Xamarin.Android 中对齐文本
Web View justify text in Xamarin.Android
如何在 Xamarin.Android 中创建带有对齐文本的 Web 视图?我想在 Web 视图控件中显示大约 10 个带有粗体、下划线和两端对齐文本的短段落。
很简单。看下面的代码。
这就是您创建新 WebView
的方式
var webViewDsc = new WebView(this)
{
LayoutParameters =
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent),
HorizontalScrollBarEnabled = false,
VerticalScrollBarEnabled = true,
};
然后你需要在WebView
里面放一个html内容
webViewDsc.LoadUrl(@"file:///android_asset/Html/...");
现在在 html 代码中调整您想要的标签
<p style="text-align:justify">
Hello!
</p>
如何在 Xamarin.Android 中创建带有对齐文本的 Web 视图?我想在 Web 视图控件中显示大约 10 个带有粗体、下划线和两端对齐文本的短段落。
很简单。看下面的代码。
这就是您创建新 WebView
var webViewDsc = new WebView(this)
{
LayoutParameters =
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent),
HorizontalScrollBarEnabled = false,
VerticalScrollBarEnabled = true,
};
然后你需要在WebView
webViewDsc.LoadUrl(@"file:///android_asset/Html/...");
现在在 html 代码中调整您想要的标签
<p style="text-align:justify">
Hello!
</p>