的WebView高度= WRAP_CONTENT不断变化的字体大小不工作 [英] WebView height = wrap_content with changing font size doesn't work

查看:1908
本文介绍了的WebView高度= WRAP_CONTENT不断变化的字体大小不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的WebView与layout_height =WRAP_CONTENT。如果我增加默认字体大小,然后的WebView高度也增加。但是,如果我降低默认字体大小,则web视图高度不会降低。因此,有对剩余的底部空的空间。

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 height doesn't decrease. So there is empty space on the bottom remaining.

下面的技巧我试过:

articleContent.getSettings().setDefaultFontSize(fontSize);
RelativeLayout.LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.BELOW, subtitleTextView.getId());
articleContent.setLayoutParams(layoutParams);

但它并没有帮助。我知道有通过重新创建的WebView与code在改变默认字体大小我来解决它的方式,但在我的情况,我不能做这样的。我需要保持的WebView,因为有一些看法娄它,我不能重新创建它们。

But it didn't help. I know there is the way to fix it by recreating WebView with a code when I changing default font size, but in my situation I can not do like that. I need to keep webview, because there are some views bellow it, and I can not recreate them too.

推荐答案

试试这个

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:orientation="vertical" >
<WebView 
    android:id="@+id/webview1"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent" />

 </LinearLayout>

这篇关于的WebView高度= WRAP_CONTENT不断变化的字体大小不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆