Android - 嵌套滚动视图内的循环器视图不滚动

时间:2018-02-09 17:48:48

标签: android scroll android-recyclerview android-nestedscrollview

我正在尝试开发一个视图,用户在滚动回收器视图时头视图会上升。但是,如果我将RecyclerView放在NestedScrollView内,那么使用xml我就无法滚动。我已设置.setNestedScrollingEnabled(false);

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/secondviewLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    android:clipToPadding="true"
    android:fillViewport="true"
    tools:context="com.futuromolise.com.futuromolise.SecondViewController">

    <android.support.constraint.ConstraintLayout
        android:id="@+id/category_list_view"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.0">

        <Button
            android:id="@+id/search_button"
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:layout_marginEnd="8dp"
            android:layout_marginTop="8dp"
            android:background="@drawable/search_icon"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="1.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/categories_news_recycler"
            android:layout_width="0dp"
            android:layout_height="40dp"
            android:layout_marginEnd="8dp"
            android:padding="0dp"
            app:layout_constraintEnd_toStartOf="@+id/search_button"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </android.support.constraint.ConstraintLayout>

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/n_scroll"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:fillViewport="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/category_list_view">

        <android.support.constraint.ConstraintLayout
            android:id="@+id/parallax_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/category_list_view">

            <android.support.constraint.ConstraintLayout
                android:id="@+id/news_first_view_header"
                android:layout_width="match_parent"
                android:layout_height="310dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <ImageView
                    android:id="@+id/first_news_imageView"
                    android:layout_width="0dp"
                    android:layout_height="0dp"
                    android:scaleType="centerCrop"
                    android:src="@drawable/molise2"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <TextView
                    android:id="@+id/first_new_title"
                    style="@style/TextShadow"
                    android:layout_width="0dp"
                    android:layout_height="0dp"
                    android:layout_marginBottom="50dp"
                    android:layout_marginEnd="16dp"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="100dp"
                    android:ellipsize="end"
                    android:fontFamily="@font/radomirextrabold"
                    android:maxLines="4"
                    android:text="n short, the views are not built yet in onCreate(), onStart(), or onResume(). Since they technically don't exist (as far as the ViewGroup is concerned), their dimensions are 0."
                    android:textAllCaps="false"
                    android:textColor="@color/white"
                    android:textSize="32sp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <com.veinhorn.tagview.TagView
                    android:id="@+id/first_new_category"
                    style="@style/TextShadow"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="8dp"
                    android:layout_marginEnd="104dp"
                    android:layout_marginStart="16dp"
                    android:fontFamily="@font/radomirextrabold"
                    android:paddingBottom="0dp"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:paddingTop="0dp"
                    android:text="@string/placeholder"
                    android:textSize="15sp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toStartOf="@+id/first_new_time"
                    app:layout_constraintHorizontal_bias="0.0"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintVertical_bias="0.538"
                    app:tagBorderRadius="50"
                    app:tagColor="@color/colorPrimaryDark"
                    app:tagType="classic" />

                <com.veinhorn.tagview.TagView
                    android:id="@+id/first_new_time"
                    style="@style/TextShadow"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="8dp"
                    android:layout_marginEnd="16dp"
                    android:layout_marginTop="8dp"
                    android:fontFamily="@font/radomirlight"
                    android:paddingBottom="0dp"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:paddingTop="0dp"
                    android:text="@string/placeholder"
                    android:textSize="12sp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintVertical_bias="0.54"
                    app:tagBorderRadius="50"
                    app:tagColor="?attr/colorControlNormal"
                    app:tagType="classic" />

            </android.support.constraint.ConstraintLayout>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/newsgrid_recyclerView"
                android:layout_width="0dp"
                android:layout_height="0dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/news_first_view_header" />

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

0 个答案:

没有答案