在NestedScrollView Android 2.3或更少版本中滚动WebView

前端之家收集整理的这篇文章主要介绍了在NestedScrollView Android 2.3或更少版本中滚动WebView前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在 @L_301_0@应用程序中添加了工具栏,Tablayout和Viewpager. TabLayout中有三个Tabs,每个都显示一个WebView.
我将WebView放置在NestedScrollView中,以便在WebView中向上/向下滚动时隐藏/显示工具栏.工具栏隐藏在Android 3.0或更高版本中.
但不幸的是,Android 2.3或更低版本的WebView不会首先滚动.我必须刷新到另一个Tab,当我再次回到第一个Tab再次WebView开始滚动.

我想要的是?

我希望WebView应该在Android 2.3或更小版本中滚动,没有任何问题.

我的WebView

<?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>

解决方法

尝试使用这个库: 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");
原文链接:https://www.f2er.com/android/312350.html

猜你在找的Android相关文章