【发布时间】:2014-07-24 13:56:59
【问题描述】:
我有一个 Webview,它看起来像 android 中的 Expandable Listview。当我将它加载到 WebView 中时,它运行良好。
但是当我把它保存在 ScrollView 中时,它会在屏幕底部添加空白
xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="300dp"
android:background="#000000"
></LinearLayout>
<WebView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/webview"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
这是在单击屏幕中的选项卡之前
点击标签后底部空白处添加,同时点击部分标签时滚动移动到底部空白处。
我的java代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scroll_example);
mwebview = (WebView) findViewById(R.id.webview);
mwebview.loadUrl("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxent-Executive/664900.html?creport=true&frompage=mobileapi");
WebSettings webSettings = mwebview.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(true);
mwebview.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
mwebview.setWebViewClient(new WebViewClient());
}
在底部添加空白,单击最后一个选项卡时会自行调整(即条款和条件)。
我真的不明白修改是必须在 PHP 端(如 Html 数据端)还是从我们的 java 端进行。
任何人都可以提出解决方案。
【问题讨论】:
-
你为什么想要一个属性为
android:layout_height="wrap_content"的ScrollView。这对你有意义吗? -
如果我保留 fill_parent 也是同样的问题
-
ScrollView 中的 Webview 是一个结构性挑战。 stackoverflow.com/questions/14255427/…
-
我也想知道为什么要把 WebView 放在 ScrollView 中?
-
是的,我有其他视图必须使用 webview 滚动,这是我的要求。我知道滚动视图中的 Webview 存在问题,但我需要这样做。
标签: android scrollview