简体   繁体   English

Web视图可在Xamarin.Android中对齐文本

[英]Web View justify text in Xamarin.Android

How do you create Web View with justified text in Xamarin.Android? 如何在Xamarin.Android中使用合理的文本创建Web视图? I would like to show about 10 short paragraphs with bold, underlined and justified text in Web View control. 我想在Web View控件中显示大约10个简短的段落,并使用粗体,带下划线和合理的文本。

It is easy. 这很容易。 Look at the following code. 看下面的代码。

This is how you create a new WebView 这是您创建新的WebView

var webViewDsc = new WebView(this)
                    {
                        LayoutParameters =
                            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent),
                        HorizontalScrollBarEnabled = false,
                        VerticalScrollBarEnabled = true,
                    };

Then you need to put a html content inside the WebView 然后,您需要在WebView放入html内容

 webViewDsc.LoadUrl(@"file:///android_asset/Html/...");

Now inside the html code justify your desired tag 现在在html代码中证明您需要的标签

<p style="text-align:justify">
  Hello!
</p>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM