android - CoordinatorLayout 中的 ViewPager 然后在屏幕外滚动 tablayout 不起作用

标签 android android-coordinatorlayout androiddesignsupport

我在 CoordinatorLayout 中有一个像这样的 viewpager:

    <android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/AppTheme"/>

    <android.support.design.widget.TabLayout
        android:id="@+id/tab_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabMode="scrollable"/>
</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

在 viewpager 中,每个 fragment 都是一个 webview。

代码可以运行,但是当我滚动我的 webview 时。屏幕外的 tablayout 不工作。它就在标题处。

更新:

我尝试使用 relativelayout 来满足我的观点,并使用 NestedScrollView 作为 relativelayout 的父级,但 webview 消失了(进度条显示正常)。是bug吗???

这是我的 fragment 布局:

<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:minHeight="300dp">

    <ProgressBar
        android:id="@+id/pb"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="fill_parent"
        android:layout_height="2dp"
        android:indeterminateOnly="false"
        android:max="100"
        android:progressDrawable="@drawable/progress_bar_states"></ProgressBar>

    <com.handmark.pulltorefresh.library.PullToRefreshWebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/pb" />
</RelativeLayout>

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

最佳答案

对于使用 NestedScrollView 时内容不显示的问题,请将“fillViewport”添加到 xml:

<android.support.v4.widget.NestedScrollView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/nestedScrollView"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:fillViewport="true">

关于android - CoordinatorLayout 中的 ViewPager 然后在屏幕外滚动 tablayout 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31426193/

相关文章:

android - Snackbar 顶部的 float 操作按钮。如何?

android - 确定 View 是否在屏幕上 - Android

android - SQLite "no such table"

android - 后台服务在android中被杀死

带有折叠工具栏的 RecyclerView 中的 Android 字母快速 ScrollView

android - 如何让CardView重叠AppBarLayout

android - 尝试检查用户是否登录时出现无限循环。google +

android - 谷歌地图和协调器布局

android - 更新到 support-v7 :27. 1.0 时 Activity 状态栏为黑色而不是透明

Android 设计支持库 : FloatingActionButon (FAB) displaying correctly on earlier versions of android and incorrectly on Lollipop