【问题标题】:Issue scrolling WebView in NestedScrollView Android 2.3 or less在 NestedScrollView Android 2.3 或更低版本中出现滚动 WebView
【发布时间】:2015-08-26 10:19:50
【问题描述】:

我在我的安卓应用中添加了Toolbar、Tablayout 和Viewpager。 TabLayout中有三个Tabs,每个都显示一个WebView。 当用户在WebView 中向下/向上滚动时,我将WebView 放在NestedScrollView 中以隐藏/显示Toolbar。 Toolbar 隐藏在 Android 3.0 或更高版本中。 但不幸的是,在 Android 2.3 或更低版本中,WebView 起初不会滚动。我必须滑动到另一个选项卡,当我再次回到第一个 Tab 时,WebView 开始滚动。

我想要什么?

我希望WebView 滚动到Android 2.3 或更少,没有任何问题。

我的网络视图

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:isScrollContainer="false"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:paddingTop="1dp">

     <WebView
         android:id="@+id/webviewtool"
         android:layout_width="match_parent"
         android:layout_height="fill_parent"
         android:numColumns="1"
         android:scrollbars="none"
         android:focusableInTouchMode="false"
         android:focusable="false"
         android:background="#FFFFFF" />

        </LinearLayout>
</android.support.v4.widget.NestedScrollView>

【问题讨论】:

    标签: android webview android-viewpager toolbar nestedscrollview


    【解决方案1】:

    尝试使用这个库:https://github.com/ksoichiro/Android-ObservableScrollView 这个库适用于 API 9+。但请记住,2.3 在视觉、动画等方面存在很多问题

    您也可以下载并查看以下代码示例:“ActionBarControlWebViewActivity WebView & Action Bar”正是您要找的。链接:ActionBar & WebView

    就这么简单:

    ObservableWebView webView = (ObservableWebView) findViewById(R.id.web);
    webView.setScrollViewCallbacks(this);
    webView.loadUrl("file:///android_asset/lipsum.html");
    

    【讨论】:

      猜你喜欢
      • 2013-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-02
      • 1970-01-01
      • 2023-03-12
      相关资源
      最近更新 更多