问题
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 perfectly fine in pre-lollipop version. But in Lollipop the font size is changing. I want it to be fixed. I have attached the screen shots for the reference.
Pre-Lollipop
Lollipop
Any help will be greatly appreciated.
P.S : Target SDK Version is 15
回答1:
I solved this.
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
来源:https://stackoverflow.com/questions/29816804/fixed-text-size-in-webview-android-lollipop