NativeScript HtmlView - different results between Android and iOS for the same Html-text

2 posts, 0 answers
  1. Marc
    Marc avatar
    30 posts
    Member since:
    Oct 2013

    Posted 30 Sep Link to this post


    we try to visualize RichText within the HtmlView component in our NativeScript app, like the following example:

        This text is striked through.
            <div style="text-align:right;">
                This text is striked through, fed and aligned right.
        <div style="text-align:center;">
            This text is italic and centered.
        This Text is underlined.


    As you can see in the Screenshots, the sample text is visualized differently on Android 6, Android 7 (Emulator) and iOS 10. We are justing just basic Html tags.

    Any hints, what we can do here?



  2. Nikolay Iliev
    Nikolay Iliev avatar
    67 posts

    Posted 05 Oct Link to this post

    Hi Marc,

    The reason this is happening is because behind HtmlView actually, we have implementations of UITextView for iOS and android.widget.TextView for Android. Now the iOS text-view has more implemented functionalities compared to the android one (for example inline styling is supported). The same applies to the different implementations of android.widget.TextView in the different API levels (we can see that in your screenshots - strike-out text is supported in Android 7 but not in Android 6). 
    Overall all of this is coming from the native behaviour of the native components that lies behind HtmlView.

    What I can suggest for more complex examples is to use WebView instead of HtmlView.
    The HtmlView is recommended only for the most basic scenario, where the WebView will use more extended mechanism  to render HTMl based content (UIWebView for iOS and  WebViewClient for Android)

    Nikolay Iliev
    Telerik by Progress

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

Back to Top