i have problem trying set webview background transparent in application. found lot of similar questions , workarounds how set webview background transparent. popular solution api > 11 is:
// color.transparent or 0x00000000 or simple 0 value webview.setbackgroundcolor(color.transparent); if (build.version.sdk_int >= 11){ setlayertype(webview.layer_type_software, null); }
however when add line setlayertype(webview.layer_type_software, null) html content in webview disappear. webview has correct scale (height of content), scroll , reacting on click or tap on (i have image-zoom system on tap). content not showing.
if remove setlayertype() method content shows fine flickering on scroll.
i use android 4.2.2 jb (api 17) , hardwareacceleration whole application set true. html-content body css set
background:transparent;
also, webview placed inside relative view 2 other textview , relativelayout itselft placed inside scrollview.
i have not found solution case - advises found setlayertype() software.
i had same problem, problem webview inside of scrollview:
<scrollview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="5dp" > <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5dp" android:text="@string/alert.resume" android:textcolor="#ff000000" android:textsize="14sp" /> <webview android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="wrap_content" /> </linearlayout> </scrollview>
then, removed scrollview , trick works!
<linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5dp" android:text="@string/alert.resume" android:textcolor="#ff000000" android:textsize="14sp" /> <webview android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="wrap_content" /> </linearlayout>
trick usual:
webview text = (webview) view.findviewbyid(r.id.webview); text.setdrawingcacheenabled(false); websettings settings = text.getsettings(); settings.setdefaulttextencodingname("utf-8"); text.setbackgroundcolor(color.transparent); if (build.version.sdk_int >= 11) // android v3.0+ try { text.setlayertype(view.layer_type_software, null); } catch (exception e) { }
Comments
Post a Comment