0

Here is im loading page in webview with url .When page is loaded i want to customize the hight of loaded page by ElementID.But not working

 WebView mywebview = (WebView)FindViewById(Resource.Id.NimID);
                Dialog = CustomProgressDialog.Show(this);
                mywebview.Settings.BuiltInZoomControls = false;
                mywebview.SetWebChromeClient(new WebChromeClient());
                mywebview.SetWebViewClient(new CustomWebViewClient(this, Dialog));
                mywebview.Settings.JavaScriptEnabled = true;
                mywebview.FocusableInTouchMode = true;
                mywebview.SetInitialScale(340);
                mywebview.Settings.DomStorageEnabled = true;
                strUrl="Something";
                 mywebview.LoadDataWithBaseURL(null, strURL, "text/html", "UTF-8", null

  

here is the class which i have created when the page is loaded the OnpagedFinished method is calling and foucs is also working but not customize of height of page is working.

public class CustomWebViewClient : WebViewClient
       {
        Android.App.Dialog Dialog;
        [Obsolete]
        public override bool ShouldOverrideUrlLoading(WebView view, string url)
        {
           
            return base.ShouldOverrideUrlLoading(view, url);
        }
        public CustomWebViewClient(NimIdLoginActivity mainActivity, Dialog dialog)
        {
           
            mActivity = mainActivity;
            Dialog = dialog;
        }
     
        public override void OnPageFinished(WebView view, string url)
        {
            Dialog.Dismiss();
       
    
            view.RequestFocus(FocusSearchDirection.Down);

//I have try this but not working to set the height of div.
          view.loadUrl( "javascript:(function(){document.getElementById('nui').style.height='1000px'})()");
            base.OnPageFinished(view, url);
       }
      
        
        public override bool ShouldOverrideUrlLoading(WebView view, IWebResourceRequest request)
        {
            return base.ShouldOverrideUrlLoading(view, request);
        }
        public override   WebResourceResponse ShouldInterceptRequest(WebView view, IWebResourceRequest request)
        {
            
            return base.ShouldInterceptRequest(view, request);
        }
  

}

Zubair Munir
  • 458
  • 3
  • 22
  • You shouldn't try to change the HTML-Content by calling URLs once a page is loaded. Why can't you change the height of the element in the HTML which is loaded? If the HTML content is also used outside of WebViews you should check if you can detect if the host is a WebView from JS within the HTML content, not the other way round. – D. McDermott Dec 15 '20 at 15:30
  • @zubairz About changing WebView height request,you can take a look [this thread](https://stackoverflow.com/questions/60399897/how-to-update-custom-webview-height-request-when-content-is-shrunk) – Cherry Bu - MSFT Dec 16 '20 at 06:55

0 Answers0