简体   繁体   English

滚动在回收器视图列表项中不起作用

[英]Scrolling is not working inside recycler-view list item

I am using a recycler-view in activity_main.xml & multiple cardviews in card_item_list.xml . 我在activity_main.xml使用了recycler-view在card_item_list.xml中使用了多个card_item_list.xml I am not able to scroll the cardviews. 我无法滚动卡片视图。 If I touch anywhere apart from cardview it is working perfectly. 如果我触摸了cardview以外的任何地方,则效果很好。 But if I tap on cardview the scrolling behavior of recycler-view is not working. 但是,如果我点击cardview,则recycler-view的滚动行为不起作用。

activity_main.xml activity_main.xml中

   <ViewFlipper
                android:id="@+id/day_navigation"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

            <ViewFlipper
                android:id="@+id/view_flipper"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="visible">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/grey_ee"
                    android:focusableInTouchMode="true"
                    android:paddingBottom="35dp">

                    <TextView
                        android:id="@+id/error_container_text"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerHorizontal="true"
                        android:layout_marginLeft="15dp"
                        android:layout_marginRight="15dp"
                        android:layout_marginTop="20dp"
                        android:elevation="1dp"
                        android:gravity="center"
                        android:padding="10dp"
                        />

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/time_duration_recycler_view"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/error_container_text"
                        android:layout_marginTop="20dp" />

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/hours_detail_recycler_view"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                       android:layout_below="@+id/time_duration_recycler_view"
                        android:layout_centerHorizontal="true"
                        android:layout_marginTop="25dp"
                        android:nestedScrollingEnabled="false" />
                </RelativeLayout>

card_item.xml card_item.xml

<RelativeLayout
    android:id="@+id/errors_and_notifications_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/divider_for_details"
    android:background="@color/white"
    android:paddingTop="15dp">

    <android.support.v7.widget.CardView
        android:id="@+id/card_view_errors"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardBackgroundColor="@color/white"
        app:cardCornerRadius="0dp"
        app:cardElevation="0dp">

        <RelativeLayout
            android:id="@+id/single_error_row"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/details"
            android:layout_marginBottom="15dp"
            android:orientation="horizontal"
            android:paddingLeft="15dp"
            android:paddingRight="15dp">

            <ImageView
                android:id="@+id/time_entry_error_image"
                android:layout_width="15dp"
                android:layout_height="15dp"
                android:layout_centerVertical="true"
                android:layout_marginLeft="5dp"
                android:src="@drawable/error" />

            <TextView
                android:id="@+id/single_error_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="45dp"/>
        </RelativeLayout>

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

    <android.support.v7.widget.CardView
        android:id="@+id/card_view_notifications"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/card_view_errors"
        app:cardBackgroundColor="@color/white"
        app:cardCornerRadius="0dp"
        app:cardElevation="0dp">

        <RelativeLayout
            android:id="@+id/single_notification_row"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="15dp"
            android:orientation="horizontal"
            android:paddingLeft="15dp"
            android:paddingRight="15dp">

            <ImageView
                android:id="@+id/time_entry_notification_image"
                android:layout_width="15dp"
                android:layout_height="15dp"
                android:layout_centerVertical="true"
                android:layout_marginLeft="5dp"
                android:src="@drawable/information" />

            <TextView
                android:id="@+id/single_notification_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="45dp"
                android:textColor="@color/black_58"
             />
        </RelativeLayout>

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

</RelativeLayout>

I have added Viewflipper as well. 我还添加了Viewflipper。 Is this a reason for it? 这是原因吗? You can able to see the first XML has two recycler-view. 您可以看到第一个XML具有两个recycler-view。 One is working fine because there are no cardviews for that recycler-view. 一个工作正常,因为该回收者视图没有卡片视图。

once try this, 尝试一下

recylerView.setHasFixedSize(true); 
recylerView.setNestedScrollingEnabled(false);

close recyclerview horizontally scrolling . 关闭recyclerview水平滚动。

     LayoutManager layoutManager = new LinearLayoutManager(this,RecyclerView.VERTICAL,false) 
    {
         @override 
         public Boolean canScrollHorizontally(){

          return false;
          }
     }

     recyclerView.setLayout(layoutManager);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么当点击它的项目时,adnroidx recycler-view 点击不起作用? - Why adnroidx recycler-view click not working when click it's item? 使用 Paging v3 时,在回收器视图中填充的多次列表项 - Multiple times list item populated in recycler-view, when using Paging v3 回收站视图项中的 ScrollView 不滚动 - ScrollView inside recycler view item is not scrolling 更改回收者视图的itemview内可绘制渐变的颜色 - Changing color of a gradient drawable inside an itemview of a recycler-view 回收者视图内的回收者视图不滚动 - Recycler View Inside Recycler View not Scrolling 在Android中的Recycler-View上添加图像时,滚动视图无法正确滚动 - Scroll-view not scrolling properly when add images on Recycler-View in android Android Studio - 为什么我的回收器视图卡住了而不让我滚动到它的底部? - Android Studio - Why my recycler-view gets stuck without leting me scrolling to it´s bottom? 在nestedscrollview中滚动多个水平回收器视图,它们之间带有视图分隔符 - scroll multiple horizonal recycler-view with view-separator between them inside nestedscrollview 单击行时的回收站视图数据绑定 - Recycler-view data binding on click of row 如何在android中的项目下方的recycler-view中减少修复阴影效果 - how to reduce fix shadow effect in recycler-view below item in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM