简体   繁体   中英

Web View justify text in Xamarin.Android

How do you create Web View with justified text in Xamarin.Android? I would like to show about 10 short paragraphs with bold, underlined and justified text in Web View control.

It is easy. Look at the following code.

This is how you create a new 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

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

Now inside the html code justify your desired tag

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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