Webview iframe overflow

前端 未结 4 1054
Happy的楠姐
Happy的楠姐 2020-12-28 12:43

I\'m currently building a web app in android. My app runs in a webview, and loads third-party contents through iframes. The iframe size is fixed and supposed not to be chang

4条回答
  •  情歌与酒
    2020-12-28 13:28

    I was trying to show an Iframe in my apps WebView, I had the problem of not being able to chop off the bottom 30px of my iframe using CSS 'overflow:hidden;'. The way I got around this was to make my own index.html file and save it locally as an asset within my app.

    If you don't have an 'assets' folder within your project, go to step 1

    (this is not the same as the 'res' folder)

    [On Windows 7]

    Step 1 - Make assets folder: In your Android Studio project click:

    File --> New --> Folder --> Assets Folder

    Image showing how to make assets folder in Windows

    Step 2 - Make the index.html that will hold your within a

    You can copy the code below to use as sample code in your index.html file:

    
        
        
            
            
        
        
            

    Step 3 - Call the index.html file in your WebView

    Note--(Id of this example WebView is 'main_ad', change this id what what ever you named your webviews id)

    WebView webView = (WebView) findViewById(R.id.main_ad);
    webView.setWebViewClient(new WebViewClient());
    webView.loadUrl("file:///android_asset/index.html");  //this is why you needed the assets folder
    webView.getSettings().setJavaScriptEnabled(true);
    

    Hope this helps even 1 person working with webviews and iframes

提交回复
热议问题