Android Webview Disable Form input Zoom - android

I've been having issues trying to get webview from stop zooming in when a user clicks a input field on webview. How can I keep webview from stop zooming in?
Heres my code:
wv = (WebView) findViewById(R.id.webView1);
WebSettings webSettings = wv.getSettings();
wv.setWebViewClient(new WebViewClient());
wv.getSettings().setLoadWithOverviewMode(true);
wv.getSettings().setUseWideViewPort(true);
wv.getSettings().setDisplayZoomControls(false);
wv.getSettings().setBuiltInZoomControls(false);
wv.getSettings().setSupportZoom (true);
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setDefaultZoom(ZoomDensity.FAR);
String form = "<form action='demo_form.asp'><input type='text' name='email' style='font-size: 200%;width:78%;float:left'><input type='submit' value='Submit' style='float:right;width:20%;font-size: 200%'></form>";
String summary = "<html><body>"+form+"</body></html>";
wv.loadData(summary, "text/html", null);

Related

webview from json string loadurl() android

i want to load url for webview from my json string. but i don't understanding what i need to do for that. i'm trying to load url using getIntent().getExtras().getString("anime_img"); but it's not working. how i can do that? i have json data for the url. here i want to load this image url in webview to open Webview Client.
JSON Data:
image: "https://website.com/library/2019/11/03/1572813810_6.jpg"
my code is:
mainWebView = (WebView)findViewById(R.id.webview);
mainWebView.setWebViewClient(new myWebclient());
mainWebView.loadUrl(getIntent().getExtras().getString("anime_img"));
WebSettings webSettings = mainWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mainWebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webSettings.setEnableSmoothTransition(true);
// Recieve data
String webview = getIntent().getExtras().getString("anime_img");
TextView tv_name = findViewById(R.id.aa_anime_name);
// setting values to each view
tv_name.setText(webview);
how i can load the webview url from my json data?
What do you send to in anime_img key? Is the " https://website.com/library/2019/11/03/1572813810_6.jpg "data returning?
So why do you show it in webview? You can display it using libraries such as Glide, Picasso in Imageview. Show this libraries. Glide , Picasso
If you say, I'll show it on webview.
// Recieve data
String webviewUrl = getIntent().getExtras().getString("anime_img");
WebSettings webSettings = mainWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mainWebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webSettings.setEnableSmoothTransition(true);
mainWebView = (WebView)findViewById(R.id.webview);
mainWebView.setWebViewClient(webSettings);
mainWebView.loadUrl(webviewUrl);
You can'll try this.
after adding this code my problems has been solved :)
String webviewUrl = getIntent().getExtras().getString("anime_img");
mainWebView = (WebView)findViewById(R.id.webview);
mainWebView.setWebViewClient(new myWebclient());
mainWebView.loadUrl(webviewUrl);
WebSettings webSettings = mainWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mainWebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webSettings.setEnableSmoothTransition(true);
special thanks to fevziomurtekin

Twitter video not loading android webview

When playing twitter video in android web view it shows the message 'by playing this video you agree to the Twitter use of cookies' and video is not played after that.
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
} else
CookieManager.getInstance().setAcceptCookie(true);
}
webView.getSettings().setJavaScriptEnabled(true);
webView.setBackgroundColor(Color.parseColor("#ffffff"));
webView.loadDataWithBaseURL("file:///android_asset/", htmlTemplate, "text/html", "UTF-8", "");
JavaScript is disabled in a WebView by default.
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
UPDATED:
Use TweetView for Native Videos
Launching native video support for Twitter Kit
Call loadDataWithBaseURL instead of loadData, like this:
loadDataWithBaseURL("https://mywebsite.com", mContent, "text/html", "UTF-8", null);

Webview is not loading facebook content

In my recyclerview I am loading webviews as items.
The Item webview may be twitter content, instagram or facebook.
my problem is that the facebook content is not loading in webview.
The html content and my binding part are given below
<iframe style="width:100%;height: 80vh;" allowfullscreen="true" allowtransparency="true" frameborder="0" height="316" scrolling="no" src="https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Fnarendramodi%2Fvideos%2F10159805167945165%2F&show_text=0&width=560" style="border:none;overflow:hidden" width="560"></iframe>
webView =(WebView)itemView.findViewById(R.id.web_view);
WebSettings settings = webView.getSettings();
settings.setDefaultTextEncodingName("utf-8");
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
webView.setFocusable(false);
webView.setClickable(true);
settings.setDomStorageEnabled(true);
settings.setJavaScriptEnabled(true);
settings.setAllowContentAccess(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setLoadsImagesAutomatically(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
} else {
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
webView.loadDataWithBaseURL(null, myHtmlString, "text/html", "UTF-8", null);

Cannot load Google Map Url in Android WebView

I try to load the Google Map Url in a WebView with the following code:
String url = "http://maps.google.com";
WebView webview = (WebView) findViewById(R.id.webview);
//webview settings
webview.setPadding(0, 0, 0, 0);
WebSettings webSettings = webview.getSettings();
webSettings.setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient());
webview.loadUrl(url);
and it cannot be loaded (blank).
But the other urls (e.g. http://www.google.com) can be loaded without any problem.
Please help !

Pdf view android studio

Hello community wanted to know how to view a PDF file in android api eight studio try these codes but can not = (someone tell me what's wrong? ..
I get all the WebView blank
  thanks
WebView wv = (WebView)findViewById(R.id.webView2);
WebSettings webSettings = wv.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
wv.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//view.loadUrl(url);
return super.shouldOverrideUrlLoading(view, url);
}
});
wv.loadUrl("www.ues.mx/Docs/alumnos/movilidad/Ejemplo%20de%20Curr%C3%ADculum%20Vitae.pdf");
wv.getSettings().setUseWideViewPort(true);
another way
WebView webview = new WebView(this);
setContentView(webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setPluginsEnabled(true);
webview.loadUrl("www.ues.mx/Docs/alumnos/movilidad/Ejemplo%20de%20Curr%C3%ADculum%20Vitae.pdf");
setContentView(webview);
PluginsEnabled replaced
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
not work in any way help!
WebView cannot display PDF documents in Android.
You can handle the pdf to either download it and then open a 3rd party app as shown here.
Or you can also use Google Drive viewer.
String myPdfUrl = "http://example.com/awesome.pdf";
String url = "http://docs.google.com/gview?embedded=true&url=" + myPdfUrl;
Log.i(TAG, "Opening PDF: " + url);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);

Categories

Resources