【问题标题】:ICS rendering webview with narrow widthICS 呈现窄宽度的 webview
【发布时间】:2012-02-21 08:04:57
【问题描述】:

所以,我有一个简单的应用程序,可以在 web 视图中加载图像板。在除 ICS 之外的大多数 Android 版本上,一切看起来都很棒。首先,渲染页面不再填充父页面,而是填充了大约 80% 的视口。其次,页面上帖子的图像和文本被包裹成窄列,占视口宽度的 45% 左右。

我意识到这可能是 4.0+ 如何读取这个 wakaba 图像板 (xhtml) 的元素的问题,但我已经碰壁了。也许有人可以解释 ICS webviews 发生了什么变化以帮助我隔离问题?这是 webkit 的问题吗?

xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
</LinearLayout>

源代码:

public void onCreate(Bundle savedInstanceState) {    
  super.onCreate(savedInstanceState);
  wv = new WebView(this);
  WebSettings webSettings = wv.getSettings();
  webSettings.setJavaScriptEnabled(true);
  webSettings.setUseWideViewPort(true);
  webSettings.setBuiltInZoomControls(true);
  webSettings.setMinimumFontSize(48);
  webSettings.setUseWideViewPort(true);
  webSettings.setLoadWithOverviewMode(true);
  webSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
  setContentView(R.layout.main );
  getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
      wv.loadUrl("http://example.com");
      wv.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
  wv.setScrollbarFadingEnabled(true);
}

被压缩的 html 帖子示例:

<span class="filesize">File: <a target="_blank" href="/b-/src/1329696064044.png">1329696064044.png</a> -(<em>1063442 B, 1433x1080</em>)</span> <span class="thumbnailmsg">Thumbnail displayed, click image for full size.</span><br />
<a target="_blank" href="/b-/src/1329696064044.png"> <img src="/b-/thumb/1329696064044s.jpg" width="500" height="376" alt="1063442" class="thumb" /></a>    <a name="2058"></a> 
<label><input type="checkbox" name="delete" value="2058" /> <span class="filetitle"></span>  <span class="postername">Anonymous</span> 02/19 17:01</label> <span class="reflink">
<a href="/b-/res/2058.html#i2058">No.2058</a>  </span>&nbsp; [<a href="/b-/res/2058.html">Reply</a>] <blockquote> <p>I&#39;m not saying he&#39;s real&#44; but he&#39;s real.<br />
<a href="http://www.youtube.com/watch?v=rkJZYxWAhUA&amp;feature=related" rel="nofollow">http://www.youtube.com/watch?v=rkJZYxWAhUA&amp;feature=related</a></p>  </blockquote>     <br clear="left" /><hr />

先发制人的感谢!

【问题讨论】:

    标签: android webkit webview android-webview android-4.0-ice-cream-sandwich


    【解决方案1】:

    我在 ICS Webview 上也遇到了这个问题,这似乎非常不可预测。

    似乎导致我的宽度窄问题的原因是setUseWideViewPort(true)setUseWideViewPort(true) 同时存在。所以只有其中一个,看看它是否能解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-30
      • 2022-10-25
      • 1970-01-01
      • 2022-08-21
      相关资源
      最近更新 更多