android - Load image from url in WebView ( center vertically ) -


i'll try load image in webview, image position in top, , need orientation center vertically.

enter image description here

this code:

. . .

mstringurl = getintent().getextras().getstring(args_image_url); 

. . .

private void initializewebview() {      mwebview.loaddatawithbaseurl(null, "<html><head><style>img {margin-top:auto;margin-bottom:auto}</style></head><body><img src=\"" + mstringurl + "\"></body></html>", "html/css", "utf-8", null);      websettings settings = mwebview.getsettings();     settings.setusewideviewport(true);     settings.setloadwithoverviewmode(true);      mwebview.setbackgroundcolor(getresources().getcolor(r.color.transparent));      mwebview.setwebviewclient(new customwebviewclient());  } 

xml file:

<include layout="@layout/layout_toolbar" />  <relativelayout     android:layout_width="match_parent"     android:layout_height="match_parent">      <webview         android:layout_width="match_parent"         android:layout_height="match_parent"         android:layout_gravity="center_vertical"         android:background="@color/black_midnight" />      <progressbar                     android:layout_width="50dp"         android:layout_height="50dp"         android:visibility="gone"         style="@android:style/widget.material.progressbar.small"         android:layout_centervertical="true"         android:layout_centerhorizontal="true" />  </relativelayout> 

if have idea please me, in advance.

try code:

mwebview.loaddatawithbaseurl(null, "<html><head></head><body><table style=\"width:100%; height:100%;\"><tr><td style=\"vertical-align:middle;\"><img src=\"" + mstringurl + "\"></td></tr></table></body></html>", "html/css", "utf-8", null); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -