android - How do I add a rotating spinner to my webview? -
i have made webview in require add loading /rotating spinner. have image same, not sure how go such when webview loads starts rotating , when entire view loaded stops. here code far:
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.fragment_search_answers, container, false); mwebview = (webview)view.findviewbyid(r.id.webview); mwebview.setvisibility(view.visible); mwebview.setwebviewclient(new mywebviewclient(this, mwebview)); mwebview.getsettings().setpluginstate(pluginstate.on); mwebview.getsettings().setusewideviewport(true); mwebview.getsettings().setdefaultzoom(zoomdensity.far); mwebview.getsettings().setbuiltinzoomcontrols(true); mwebview.getsettings().setsupportzoom(true); mwebview.getsettings().setjavascriptcanopenwindowsautomatically(true); mwebview.getsettings().setallowfileaccess(true); mwebview.getsettings().setdomstorageenabled(true); mwebview.getsettings().setjavascriptenabled(true); mwebview.sethttpauthusernamepassword(host, realm, username, password); mwebview.getsettings().setappcacheenabled(true); if (build.version.sdk_int >= build.version_codes.honeycomb) mwebview.getsettings().setdisplayzoomcontrols(false); mwebview.loadurl(url); return view; }
p.s:i add constant animated rotation. here code rotate.xml added under animations:
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <rotate android:fromdegrees="180.0" android:todegrees="0.0" android:pivotx="50%" android:pivoty="50%" android:duration="200" /> </set>
any idea how can connect webview imae , rotate.xml meets expected criteria?
thanks! justin
the solution easy: below line:
view view = inflater.inflate(r.layout.fragment_search_answers, container, false); mwebview = (webview)view.findviewbyid(r.id.webview);
add:
mpbar = (progressbar) view.findviewbyid(r.id.web_view_progress);
after setting in title as:
private progressbar mpbar = null;
and go web view client section , add :
@override public void onpagestarted(webview view, string url, bitmap favicon) { mpbar.setvisibility(view.visible); }
and :
public void onpagefinished(webview view, string url) { mpbar.setvisibility(view.gone); }
ad not forget set <progressbar
style , required width height below <webview>
in xml , wonders.
Comments
Post a Comment