![](/img/trans.png)
[英]Android NestedScrollView not scrolling in the NestedScrollView
[英]Issue scrolling WebView in NestedScrollView Android 2.3 or less
我在我的Android應用程序中添加了Toolbar
, Tablayout
和Viewpager
。 TabLayout
有三個Tabs
,每個Tabs
都顯示一個WebView
。 當用戶在WebView
向下/向上滾動時,我將WebView
放在NestedScrollView
以隱藏/顯示Toolbar
。 Toolbar
隱藏在Android 3.0或更高版本中。 但不幸的是,在Android 2.3或更低版本中, WebView
最初不會滾動。 我必須刷到另一個標簽,當我再次回到第一個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");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.