【问题标题】:Scroll-bar is not visible in <div> in WebView滚动条在 WebView 的 <div> 中不可见
【发布时间】:2012-06-27 06:00:01
【问题描述】:

我有一个包含滚动分区的 Html 文件。当我在 WebView 中添加此 HTML 时,它不会显示该 div 的滚动条。

我在 Html 文件中有代码。

// some Html code


<table style="border: 3px solid black;" align="center">
 <tr>
<td ><div style="width: 100%; height: 50px; overflow: auto;  padding:0px; "> <div>
  put returns between paragraphs
► for linebreak add 2 spaces at end
► _italic_ or **bold**
► indent code by 4 spaces
► backtick escapes `like _so_`
► quote by placing > at start of line
► to make links
<http://foo.com>
 [foo](http://foo.com)
► basic HTML also allowed

 </div></td>
</tr>
</table>

// some Html code

当我在 xml 文件中的 WebView 中添加这个 Html 文件时。

XML 的代码是...

//一些Html代码

<RelativeLayout
    android:id="@+id/webLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/buttonLayout"
    android:layout_below="@+id/titleLayout" >

    <WebView
        android:id="@+id/webViewMain"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </WebView>
</RelativeLayout>

//一些Html代码

它工作正常,但不显示添加到 Html 文件中的那个 Div 的滚动条

【问题讨论】:

  • 你试过使用WebChromeClient吗?
  • @KevinQiu 检查已编辑的问题。

标签: android html webview


【解决方案1】:

目前在 Android 上无法使用 overflow:auto 滚动 div。 但是您可以通过结合使用 HTML、JavaScript 和 CSS 进行一些工作来实现相同的目的。详情见this链接。

另一种解决方案是,您可以使用iScroll 库。

为了您的信息,here is a nice comparison of what may or may not and how work on various mobile browsers

【讨论】:

  • 我看到了比较,但我想要任何替代解决方案。
  • 我已经在上面的回答中提出了两种解决方法。你试过了吗?
  • 我看到了你的回答,但我不想让按钮滚动。我想要没有按钮的普通可触摸和可滚动视图。
猜你喜欢
  • 1970-01-01
  • 2017-05-11
  • 1970-01-01
  • 1970-01-01
  • 2023-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多