WebView height = wrap_content with changing font size doesn't work

后端 未结 7 1640
醉话见心
醉话见心 2020-12-19 06:54

I have webview with layout_height = \"wrap_content\". If I increase default font size, then webview height increases too. But if I decrease default font size, then webview h

7条回答
  •  悲哀的现实
    2020-12-19 07:01

    The only solution I have found that actually works, is in the com.android.email client that comes with the Android Open Source Project. There, they have a RigidWebView which works with the wrap_content and will resize accordingly when the content changes. Source code for this can be found here:

    https://android.googlesource.com/platform/packages/apps/Email/+/c19c1226da4a32e49e81c202478384f0348bcfef/src/com/android/email/view/RigidWebView.java

    You'll need the Clock and Throttle classes that come with it, but with minor changes to the code, you can make it so it works in your app. Then anywhere where you would normally define a WebView, you can use RigidWebView instead.

提交回复
热议问题