Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello, I don't know if I can get the height of InAppWebView or make it adapt to the height of Html content. What do I need to do? #35

Closed
JiangJuHong opened this issue Jan 5, 2019 · 10 comments
Labels

Comments

@JiangJuHong
Copy link

Hello, I don't know if I can get the height of InAppWebView or make it adapt to the height of Html content. What do I need to do?

@Shahxad-Akram
Copy link

Did you find any idea?

@juliengit2
Copy link

juliengit2 commented Mar 11, 2019

I had to add:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
to adapt the size of the html content to the size of the InAppWebView

@YouCii
Copy link
Contributor

YouCii commented Mar 12, 2019

@juliengit2 The code only allows HTML pages to be adapted to mobile devices, but the height is not the biggest.

@honghuazhao
Copy link

You can inject js code to do this, like:

controller.injectScriptCode('''
window.flutter_inappbrowser.callHandler('WebViewHeight', document.body.scrollHeight);
''');

But you still cannot set the height of InAppWebView to this height. It will crash on android because android (or flutter) doesn't support height more than device height.

@goYou
Copy link

goYou commented Apr 16, 2020

This may help you:

onLoadStop: (InAppWebViewController controller, String url) {
              controller.evaluateJavascript(source: '''(() => { return document.body.scrollHeight;})()''').then((value) {
                if(value == null || value == '') {
                  return;
                }
                webHeight = double.parse('$value');
                setState(() {});
              });
            },

@sketcharsh
Copy link

This can also give you same result.

controller .getContentHeight() .then((value) => print("Value $value"));

@wilz05
Copy link

wilz05 commented Jan 4, 2022

but the above code does not work on android api version 22 devices. have you tried ? @sketcharsh @goYou

@sketcharsh
Copy link

I've not checked in android api version 22 devices.

Copy link

github-actions bot commented Oct 8, 2024

This issue is stale and has been automatically closed because it has been open for more than 365 days with no activity. Please reopen a new issue if you still have it.

@github-actions github-actions bot added the stale label Oct 8, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 8, 2024
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

8 participants