Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 嵌套滚动视图内的水平循环视图,can';不要垂直滚动_Android_Android Recyclerview_Horizontalscrollview_Android Nestedscrollview - Fatal编程技术网

Android 嵌套滚动视图内的水平循环视图,can';不要垂直滚动

Android 嵌套滚动视图内的水平循环视图,can';不要垂直滚动,android,android-recyclerview,horizontalscrollview,android-nestedscrollview,Android,Android Recyclerview,Horizontalscrollview,Android Nestedscrollview,我尝试了各种组合,有些人说这是一个bug,但我认为我缺少了一些小东西。使用下面的XML,我根本无法滚动,只有水平滚动可以工作 我有一个侧面滚动回收视图,我可以左右拖动,但页面上的I项太多,无法容纳,因此滚动视图 起初,我的目标是一个可折叠的工具栏,但当我添加CoordinatorLayout时,活动只是空白 我的XML: <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.co

我尝试了各种组合,有些人说这是一个bug,但我认为我缺少了一些小东西。使用下面的XML,我根本无法滚动,只有水平滚动可以工作

我有一个侧面滚动回收视图,我可以左右拖动,但页面上的I项太多,无法容纳,因此滚动视图

起初,我的目标是一个可折叠的工具栏,但当我添加CoordinatorLayout时,活动只是空白

我的XML:

<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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:nestedScrollingEnabled="true"
    app:layout_constraintTop_toBottomOf="@+id/scrollv"
    tools:context="com.wearecatchapp.blueandwhite.catchapp_droid.EventDetailActivity">

    <android.support.v7.widget.Toolbar
        android:id="@+id/detail_toolbar"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="#fff"
        android:elevation="2dp"
        android:minHeight="60dp"
        android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_scrollFlags="scroll|enterAlwaysCollapsed"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:gravity="center"
            android:orientation="vertical">

            <TextView
                android:id="@+id/evt_title"
                fontPath="fonts/PanameFY.otf"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:textAlignment="center"
                android:textColor="@color/black"
                android:textSize="30sp" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:padding="2dp"
                    android:text="Organizer's level:"
                    android:textAlignment="center"
                    android:textColor="@color/black"
                    android:textSize="12sp" />

                <ImageView
                    android:id="@+id/org_level"
                    android:layout_width="60dp"
                    android:layout_height="16dp"
                    android:layout_gravity="center_vertical" />
            </LinearLayout>

            <TextView
                android:id="@+id/optional_title"
                fontPath="fonts/PanameFY.otf"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:padding="2dp"
                android:textAlignment="center"
                android:textColor="@color/black"
                android:textSize="24sp"
                android:visibility="gone" />

        </LinearLayout>

    </android.support.v7.widget.Toolbar>


    <android.support.v4.widget.NestedScrollView
        android:id="@+id/scrollv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@+id/detail_toolbar">

        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">


            <ImageView
                android:id="@+id/activity_image"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"

                app:srcCompat="@color/black" />

            <TextView
                android:id="@+id/month"
                android:layout_width="70dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="8dp"
                android:text="NOV"
                android:textAlignment="center"
                android:textColor="@android:color/holo_red_light"
                android:textSize="18sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/activity_image" />

            <TextView
                android:id="@+id/day"
                android:layout_width="70dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="2dp"
                android:text="15"
                android:textAlignment="center"
                android:textColor="@color/black"
                android:textSize="24sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/month" />

            <TextView
                android:id="@+id/starts"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="8dp"
                android:text="Starts"
                android:textColor="@color/black"
                android:textSize="18sp"
                app:layout_constraintLeft_toRightOf="@+id/month"
                app:layout_constraintTop_toBottomOf="@+id/activity_image" />

            <TextView
                android:id="@+id/ends"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="7dp"
                android:text="Ends"
                android:textColor="@color/black"
                android:textSize="18sp"
                app:layout_constraintLeft_toRightOf="@+id/day"
                app:layout_constraintTop_toBottomOf="@+id/starts" />

            <TextView
                android:id="@+id/start_date"
                fontPath="fonts/AvenirNext-Medium.ttf"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="42dp"
                android:layout_marginStart="42dp"
                android:layout_marginTop="8dp"
                android:text=" 18:10   Wed, Nov 15"
                android:textColor="@color/black"
                android:textSize="18sp"
                app:layout_constraintLeft_toRightOf="@+id/starts"
                app:layout_constraintTop_toBottomOf="@+id/activity_image" />

            <TextView
                android:id="@+id/textView34"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="50dp"
                android:layout_marginStart="50dp"
                android:layout_marginTop="7dp"
                android:textColor="@color/black"
                android:textSize="18sp"
                app:layout_constraintLeft_toRightOf="@+id/ends"
                app:layout_constraintTop_toBottomOf="@+id/start_date" />

            <View
                android:id="@+id/view10"
                id="@+id/view8"
                android:layout_width="0dp"
                android:layout_height="1dp"
                android:layout_marginTop="16dp"
                android:background="@color/thegray"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/linearLayout2" />

            <View
                android:id="@+id/view9"
                android:layout_width="0dp"
                android:layout_height="1dp"
                android:layout_marginTop="9dp"
                android:background="@color/thegray"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textView34" />

            <LinearLayout
                android:id="@+id/linearLayout"
                android:layout_width="397dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="25dp"
                android:orientation="horizontal"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textView34">

                <ImageView
                    android:id="@+id/requests_image"
                    android:layout_width="24dp"
                    android:layout_height="24dp"
                    android:layout_weight="1"
                    app:srcCompat="@drawable/requestsicon" />

                <ImageView
                    android:id="@+id/invite_image"
                    android:layout_width="24dp"
                    android:layout_height="24dp"
                    android:layout_weight="1"
                    app:srcCompat="@drawable/invitefriends" />

                <ImageView
                    android:id="@+id/recommend_image"
                    android:layout_width="24dp"
                    android:layout_height="24dp"
                    android:layout_weight="1"
                    app:srcCompat="@drawable/recommend" />

                <ImageView
                    android:id="@+id/share_image"
                    android:layout_width="24dp"
                    android:layout_height="24dp"
                    android:layout_weight="1"
                    app:srcCompat="@drawable/shareblue" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/linearLayout2"
                android:layout_width="396dp"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/linearLayout">

                <TextView
                    android:id="@+id/requests_text"
                    fontPath="fonts/avenir-next-bold.ttf"
                    android:layout_width="24dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="Requests"
                    android:textAlignment="center"
                    android:textColor="@color/black"
                    android:textSize="12sp" />

                <TextView
                    android:id="@+id/invite_friends_text"
                    fontPath="fonts/avenir-next-bold.ttf"
                    android:layout_width="24dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="Invite friends"
                    android:textAlignment="center"
                    android:textColor="@color/black"
                    android:textSize="12sp" />

                <TextView
                    android:id="@+id/recommend_event_text"
                    fontPath="fonts/avenir-next-bold.ttf"
                    android:layout_width="24dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="Recommend"
                    android:textAlignment="center"
                    android:textColor="@color/black"
                    android:textSize="12sp" />

                <TextView
                    android:id="@+id/share_text"
                    fontPath="fonts/avenir-next-bold.ttf"
                    android:layout_width="24dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="Share"
                    android:textAlignment="center"
                    android:textColor="@color/black"
                    android:textSize="12sp" />
            </LinearLayout>

            <TextView
                android:id="@+id/status_text"
                fontPath="fonts/avenir-next-bold.ttf"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:paddingLeft="8dp"
                android:textColor="@color/dark_gray"
                android:textSize="20sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/view10" />

            <ImageView
                android:id="@+id/is_for"
                android:layout_width="36dp"
                android:layout_height="36dp"
                android:layout_marginLeft="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="6dp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/status_text"
                app:srcCompat="@drawable/maleandfemale" />

            <TextView
                android:id="@+id/going"
                fontPath="fonts/AvenirNext-Medium.ttf"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="15dp"
                android:text="going"
                android:textColor="@color/black"
                app:layout_constraintLeft_toRightOf="@+id/is_for"
                app:layout_constraintTop_toBottomOf="@+id/status_text" />

            <TextView
                android:id="@+id/more_togo"
                fontPath="fonts/AvenirNext-Medium.ttf"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:layout_marginStart="20dp"
                android:layout_marginTop="15dp"
                android:text="TextView"
                android:textColor="@color/black"
                app:layout_constraintLeft_toRightOf="@+id/hor_view"
                app:layout_constraintTop_toBottomOf="@+id/status_text" />

            <View
                android:id="@+id/hor_view"
                class="android.support.v4.widget.Space"
                android:layout_width="1dp"
                android:layout_height="30dp"
                android:layout_marginLeft="35dp"
                android:layout_marginStart="35dp"
                android:layout_marginTop="8dp"
                android:background="@color/dark_gray"
                app:layout_constraintLeft_toRightOf="@+id/going"
                app:layout_constraintTop_toBottomOf="@+id/status_text" />

            <android.support.v7.widget.RecyclerView
                android:id="@+id/participants_list"
                android:layout_width="0dp"
                android:layout_height="117dp"
                android:layout_marginTop="12dp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/hor_view" />

            <View
                android:id="@+id/view16"
                android:layout_width="0dp"
                android:layout_height="1dp"
                android:layout_marginTop="8dp"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/participants_list" />

            <TextView
                android:id="@+id/textView47"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="17dp"
                android:text="Costs"
                android:textSize="18sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/view16" />

            <TextView
                android:id="@+id/cost_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginTop="17dp"
                android:text="TextView"
                android:textSize="18sp"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/view16" />

            <View
                android:id="@+id/view19"
                android:layout_width="0dp"
                android:layout_height="1dp"
                android:layout_marginTop="55dp"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/view16" />

            <TextView
                android:id="@+id/cost_title_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="13dp"
                android:textSize="18sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/view19" />

            <View
                android:id="@+id/view20"
                android:layout_width="0dp"
                android:layout_height="1px"
                android:layout_marginTop="16dp"
                android:background="@color/thegray"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/view19" />

            <ImageView
                android:id="@+id/imageView15"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_marginLeft="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="16dp"
                android:padding="8dp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/view20"
                app:srcCompat="@drawable/pinblue" />

            <TextView
                android:id="@+id/textView50"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="7dp"
                android:layout_marginStart="7dp"
                android:layout_marginTop="16dp"
                android:text="Event location"
                android:textColor="@color/colorPrimary"
                android:textSize="18sp"
                app:layout_constraintLeft_toRightOf="@+id/imageView15"
                app:layout_constraintTop_toBottomOf="@+id/view20" />

            <ImageView
                android:id="@+id/imageView5"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_marginLeft="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="16dp"
                android:padding="8dp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textView50"
                app:srcCompat="@drawable/background" />
        </android.support.constraint.ConstraintLayout>

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


    <android.support.v7.widget.CardView
        android:layout_width="0dp"
        android:layout_height="60dp"
        android:layout_marginBottom="29dp"
        android:layout_marginEnd="40dp"
        android:layout_marginLeft="40dp"
        android:layout_marginRight="40dp"
        android:layout_marginStart="40dp"
        app:cardBackgroundColor="@color/colorPrimary"
        app:cardCornerRadius="18dp"
        app:cardElevation="16dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent">


        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal"
            android:text="REQUEST TO JOIN"
            android:textColor="@android:color/white"
            android:textSize="14dp" />
    </android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>


看在上帝的份上,请给我解释一下这个问题。

试着在你的内部循环视图中添加
setNestedScrollingEnabled(false)

setNestedScrollingEnabled

启用或禁用此视图的嵌套滚动

如果此属性设置为true,则允许启动视图 中具有兼容父视图的嵌套滚动操作 当前层次结构。如果此视图未实现嵌套滚动 这不会有任何效果。嵌套时禁用嵌套滚动 正在进行的滚动具有停止嵌套滚动的效果

1) xml

android.support.v4.widget.NestedScrollView 内部使用线路布局

(二) recyclerView=(recyclerView)view.findViewById(R.id.recyclerView\u main);
recyclerView.setNestedScrollingEnabled(false)

如果有人仍然面临这个问题,请注意两件事:

  • 您的
    NestedScrollView
    高度应为
    match\u parent
    。如果您使用的是
    NestedScrollView
    内部
    ConstraintLayout
    可以通过以下代码行实现

    android:layout_height="0dp"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    
  • 在您的
    RecyclerView

    android:nestedScrollingEnabled=“false”

  • 我希望这将节省其他人的时间。

    添加此行mRecyclerView.setNestedScrollingEnabled(false);在onCreate方法中