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?

Answers

  • 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.

    http://developer.android.com/guide/topics/ui/themes.html

  • 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.

    http://docs.xamarin.com/guides/android/user_interface/working_with_listviews_and_adapters/part_3_-_customizing_a_listview's_appearance

Sign In or Register to comment.