Fixed text size in WebView Android (Lollipop)

I have this simple code in WebView

 <tr><td valign='top' width='30%'><span style='font-size:11px !important;'> @label</span></td><td valign='top' width='2%'><span style='font-size:11px !important;'>:</span></td><td ><span style='font-size:11px !important;word-break:keep-all;'> @val</span></td></tr>

      

How to have fixed font size of 11px?

If I increase / decrease the system font size in display settings, the above code works fine in the pre-lellipop version. But in Lollipop, the font size changes. I want this to be fixed. I have attached screenshots for reference.

Pre-lollipop

Pre-Lollipop

lollipop

Lollipop

Any help would be greatly appreciated.

PS: SDK version for target is 15

+3


source to share


1 answer


I solved it.

settings.setTextZoom (100);



@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    WebView webview = (WebView) findViewById(R.id.webview);
    WebSettings settings = webview.getSettings();
    settings.setJavaScriptEnabled(true);

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH)
        settings.setTextZoom(100);

    webview.loadUrl("http://www.google.co.kr");
}

      

http://1004lucifer.blogspot.kr/2015/05/android-webview-lollipop.html

+4


source







All Articles