Forum Xamarin Xamarin.Android

Best way to set text size in WebView?

What's the best way to do this? Everything I've tried doesn't adjust the text size when I set my Accessibility preferences for my device to Large Text.

I'm using WebViews to let me style things with CSS, especially to use <ul>s to format lists. Is there a way to feed html to a TextView? If so, would this be a better approach than using WebViews?


  • rmaciasrmacias USBeta, University ✭✭✭✭✭

    Yeah, you can feed HTML into a text view and it can render it. Not sure if it supports CSS, but you can do something like:

    var htmlCode = "<ul><li>Item 1</li><li>Item 2</li></ul>";
    var myTextView = FindViewById<TextView>(Resource.Id.myTextView);
    myTextView.TextFormatted = Android.Text.Html.FromHtml(htmlCode);

    That should render it.

  • rmaciasrmacias USBeta, University ✭✭✭✭✭

    And on another philosophical note, I would recommend against using WebViews to display your content and stick to native controls. You will keep your sanity and it will be a better experience for your users. If you need to keep a "css" like style common, you can use styles and themes.

  • deeeeerodeeeeero USMember

    Yes, I was getting that impression. But I have a lot of bulleted lists that I'd like to display. What's the best way to handle those?

  • rmaciasrmacias USBeta, University ✭✭✭✭✭

    A couple of ways. The easiest would be to like the code I posted above that transforms Html into formatted text to be viewed in a TextView.

    Another method, is to use ListView. You can customize each individual view to show a bullet point image.'s_appearance

Sign In or Register to comment.