Android 8: WebView - vertical scrollbar - incorrect work -
i has activity webview. here layout xml:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <webview android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="match_parent" /> </linearlayout>
here activity code:
public class testactivity extends appcompatactivity { public static final string html_text = "html_text"; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.test_activity); string htmltext = getintent().getextras().getstring(html_text); webview webview = (webview) findviewbyid(r.id.webview); webview.getsettings().setjavascriptenabled(true); string resulthtml = "<html><head><meta charset=utf-8></head><body>" + htmltext + "</body></html>"; webview.loaddatawithbaseurl("fake://", resulthtml, "text/html", stringutil.encodingutf8, null); } }
and here result:
and can see on right side success show scrollbar when scrolling. work on android 4.0, 5.0, 6.0, 7.0. ok.
but on android 8.0 (emulator) when scrolling item "test many posts 7/15" (about half screen) scrollbar hide. i'm scrolling bottom of screen scrollbar not show.
here result:
and scrolling bottom of screen (scrollbar hide):
how fix this?
in oncreate()
method try :
@override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.your_web_view_layout); browser = (webview)findviewbyid(r.id.your_webview); websettings mwebsettings = browser.getsettings(); mwebsettings.setbuiltinzoomcontrols(true); browser.setscrollbarstyle(webview.scrollbars_outside_overlay); browser.setscrollbarfadingenabled(false); browser.loadurl("file:///android_asset/index.html"); }
Comments
Post a Comment