android - WebView with an image doesnt stay in center after zoom(double tap) -
i have been trying show image in webview. image large , of dimensions bigger device. chose use webview
capable of showing large images.
however, difficult show webview
image inside layout , keep around center. following code image shows fine in center in beginning start double tapping zooms in , zooms out , moves on screen. settles aligned top of device scree , wont wont move there.
i missing here. there specific ways achieve center aligned image in webview
?
what looking is:
- webview should expand , collapse double tap toggles
- image should zoom in , zoom out zoom should respect image position in center. should come in original position when zoomed out.
any appreciated thanks
here layout xml:
<framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:scaletype="centerinside" android:background="@android:color/holo_green_dark"> <webview android:id="@+id/test" android:layout_width="wrap_content" android:layout_height="wrap_content" android:adjustviewbounds="true" android:layout_marginleft = "10dp" android:layout_marginright = "10dp" android:layout_gravity="center" android:scaletype="centerinside" /> </framelayout>
here activity source code:
public class testactivity7 extends activity { string largeurl = "http://test.png"; webview webview; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.test); webview = (webview) findviewbyid(r.id.test); websettings websettings = webview.getsettings(); websettings.setdisplayzoomcontrols(false); websettings.setdisplayzoomcontrols(false); websettings.setsupportzoom(false); websettings.setjavascriptenabled(true); websettings.setusewideviewport(true); websettings.setloadwithoverviewmode(true); websettings.setdefaulttextencodingname("utf-8"); // websettings.setusewideviewport(true); webview.setinitialscale(25); webview.setbackgroundcolor(color.transparent); webview.loadurl(largeurl); } }
Comments
Post a Comment