Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.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 RecyclerView中的RecyclerView_Android_Android Layout_Android Recyclerview - Fatal编程技术网

Android RecyclerView中的RecyclerView

Android RecyclerView中的RecyclerView,android,android-layout,android-recyclerview,Android,Android Layout,Android Recyclerview,我有一个RecyclerView,里面的每个项目都有一个RecyclerView: fragment\u active\u goals.xml(包含外部回收视图): 对于内部RecyclerView我使用库(答案解释了内部RecyclerView的工作原理)。现在,内部的RecyclerView不会滚动,但是外部的会滚动。如何使内部的RecyclerView可滚动,而不是外部的RecyclerView 此外,我还希望能够水平滑动,而不仅仅是垂直滚动 非常感谢您的帮助(:RecyclerView

我有一个
RecyclerView
,里面的每个项目都有一个
RecyclerView

fragment\u active\u goals.xml
(包含外部回收视图):

对于内部
RecyclerView
我使用库(答案解释了内部
RecyclerView
的工作原理)。现在,内部的
RecyclerView
不会滚动,但是外部的会滚动。如何使内部的
RecyclerView
可滚动,而不是外部的
RecyclerView

此外,我还希望能够水平滑动,而不仅仅是垂直滚动


非常感谢您的帮助(:

RecyclerView
实现了
NestedScrollingChild2
inteface,但没有实现任何
NestedScrollingParent*
接口,因此它可以是可滚动的子级,但不能是此类子级的父级。
要使其正常工作,您需要创建一个子类
RecyclerView
,并自己实现
NestedScrollingParent
接口。例如,也有一些文章介绍了如何做到这一点。

RecyclerView有一个NestedScroll标志,您是否设置了它(我不确定它是否应该设置在内部或外部)尝试在xml中并以编程方式在内部和外部标记上使用此标记,但仍然不起作用…:/you share your xml?添加了相关的.xml文件。内部
RecyclerView
s项没有.xml文件,它们只是我创建的一个自定义对象,名为CustomProgressBarButtoncreate一个可以复制sa的虚拟项目我是你面临的问题。有了这些人可以更好地帮助你谢谢你!解决方案是完美的(:。我在文章中使用了准确的代码,它工作得非常完美!
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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/parent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".fragments.ActiveGoalsFragment">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">


            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/recycler_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/light_gray"
                android:clipChildren="false"
                android:clipToPadding="false"
                android:nestedScrollingEnabled="false"
                android:scrollbars="vertical" />


        </RelativeLayout>

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            android:layout_margin="20dp"
            android:src="@drawable/plus"
            app:fabSize="normal" />

        <com.github.mmin18.widget.RealtimeBlurView
            android:id="@+id/blur_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:realtimeBlurRadius="20dp"
            app:realtimeOverlayColor="#8000"
            android:elevation="5dp"
            android:visibility="gone"/>

        <com.google.android.material.circularreveal.CircularRevealFrameLayout
            android:id="@+id/fragment_container"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:elevation="10dp"
            android:layout_margin="15dp"
            android:visibility="invisible"
            app:layout_behavior="com.google.android.material.transformation.FabTransformationSheetBehavior">

            <com.google.android.material.card.MaterialCardView
                android:id="@+id/dialog"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                app:cardCornerRadius="15dp"
                app:cardPreventCornerOverlap="true">

                <RelativeLayout
                    android:id="@+id/pr"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/add_new_active_activity_dialog_background"
                    android:gravity="center"
                    android:padding="15dp">

                    <TextView
                        android:id="@+id/name_label"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:text="@string/name_of_new_goal_label_dialog"
                        android:textSize="20sp" />

                    <EditText
                        android:id="@+id/name_et"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/name_label"
                        android:hint="@string/name_of_new_goal_hint_dialog"
                        android:textSize="20sp" />

                    <TextView
                        android:id="@+id/description_label"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/name_et"
                        android:layout_gravity="center"
                        android:text="@string/description_of_new_goal_label_dialog"
                        android:textSize="20sp" />

                    <EditText
                        android:id="@+id/description_et"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/description_label"
                        android:hint="@string/description_of_new_goal_hint_dialog"
                        android:textSize="20sp" />

                    <RelativeLayout
                        android:id="@+id/cancel_btn"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/description_et"
                        android:layout_alignStart="@id/name_et"
                        android:layout_margin="15dp"
                        android:background="@drawable/ripple_button_background"
                        android:clickable="true"
                        android:elevation="8dp"
                        android:focusable="true"
                        android:padding="15dp">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/cancel_adding_new_goal_dialog_button_text"
                            android:textAllCaps="false"
                            android:textColor="@color/brain1" />

                    </RelativeLayout>

                    <RelativeLayout
                        android:id="@+id/add_btn"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/description_et"
                        android:layout_alignEnd="@id/description_et"
                        android:layout_margin="15dp"
                        android:background="@drawable/ripple_button_background"
                        android:clickable="true"
                        android:elevation="8dp"
                        android:focusable="true"
                        android:padding="15dp">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/add_new_goal_dialog_button_text"
                            android:textAllCaps="false"
                            android:textColor="@color/brain1" />

                    </RelativeLayout>

                </RelativeLayout>

            </com.google.android.material.card.MaterialCardView>

        </com.google.android.material.circularreveal.CircularRevealFrameLayout>

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:focusable="true">


    <FrameLayout
        android:id="@+id/cardHolder"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


        <androidx.cardview.widget.CardView
            android:id="@+id/acardView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            app:cardCornerRadius="15dp"
            app:cardElevation="10dp">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <RelativeLayout
                    android:id="@+id/aroot_view_per_active_goal"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <LinearLayout
                        android:id="@+id/aactive_goal_card"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="4dp"
                        android:orientation="horizontal"
                        android:padding="10dp"
                        android:weightSum="11">

                        <com.example.performancemeasurement.customViews.CustomProgressBar.CustomProgressBar
                            android:id="@+id/aactive_goal_item_progress_bar"
                            android:layout_width="0dp"
                            android:layout_height="50dp"
                            android:layout_weight="9"
                            android:transitionName="progressBar"
                            android:visibility="visible"
                            app:enable_gradient="true" />

                        <ImageButton
                            android:id="@+id/aactive_goal_item_edit_image_button"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="?attr/selectableItemBackground"
                            android:contentDescription="shrunk"
                            android:scaleType="fitCenter"
                            android:src="@drawable/edit_vector" />

                        <ImageButton
                            android:id="@+id/aactive_goal_item_open_close_image_button"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="?attr/selectableItemBackground"
                            android:contentDescription="shrunk"
                            android:scaleType="fitCenter"
                            android:src="@drawable/down_vector" />

                    </LinearLayout>

                    <RelativeLayout
                        android:id="@+id/aexpanded_active_goal_card"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="4dp"
                        android:visibility="visible">

                        <androidx.constraintlayout.widget.ConstraintLayout
                            android:id="@+id/aactive_goal_item_back_to_parent_image_button_container"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:clickable="false"
                            android:focusable="false"
                            android:layout_alignParentTop="true"
                            android:layout_alignParentStart="true"
                            android:layout_alignBottom="@id/aexpanded_active_goal_card_label">

                            <ImageButton
                                android:id="@+id/aactive_goal_item_back_to_parent_image_button"
                                android:layout_width="0dp"
                                android:layout_height="match_parent"
                                app:layout_constraintDimensionRatio="1:1"
                                android:src="@drawable/ic_arrow_back_black_24dp"
                                android:background="?attr/selectableItemBackground"
                                app:layout_constraintTop_toTopOf="parent"
                                app:layout_constraintStart_toStartOf="parent"/>

                        </androidx.constraintlayout.widget.ConstraintLayout>


                        <TextView
                            android:id="@+id/aexpanded_active_goal_card_label"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_margin="10dp"
                            android:layout_centerHorizontal="true"
                            android:text="Goal Name"
                            android:textColor="@android:color/black"
                            android:textSize="40sp"
                            android:textStyle="bold" />

                        <com.developer.mtextfield.TextFieldBoxes
                            android:id="@+id/aexpanded_active_goal_card_edit_label_field_box"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_margin="10dp"
                            android:layout_centerHorizontal="true"
                            app:labelText="Goal Name:"
                            android:visibility="invisible" >

                            <com.developer.mtextfield.ExtendedEditText
                                android:id="@+id/aexpanded_active_goal_card_edit_label_edit_text"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"/>

                        </com.developer.mtextfield.TextFieldBoxes>


                        <com.example.performancemeasurement.customViews.CustomProgressBar.CustomProgressBar
                            android:id="@+id/aexpanded_active_goal_card_progress_bar"
                            android:layout_width="wrap_content"
                            android:layout_height="30dp"
                            android:layout_below="@id/aexpanded_active_goal_card_label"
                            android:layout_alignParentStart="true"
                            android:layout_alignParentEnd="true"
                            android:layout_marginStart="20dp"
                            android:layout_marginEnd="20dp"
                            android:layout_centerHorizontal="true"
                            android:transitionName="progressBar"
                            app:enable_gradient="true" />

                        <TextView
                            android:id="@+id/aexpanded_active_goal_card_description"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@id/aexpanded_active_goal_card_progress_bar"
                            android:layout_centerHorizontal="true"
                            android:layout_margin="10dp"
                            android:maxLines="3"
                            android:text="Goal's Description"
                            android:textColor="#6F6F6F"
                            android:textSize="20sp"
                            android:textStyle="normal" />

                        <com.developer.mtextfield.TextFieldBoxes
                            android:id="@+id/aexpanded_active_goal_card_edit_description_field_box"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@id/aexpanded_active_goal_card_progress_bar"
                            android:layout_centerHorizontal="true"
                            android:layout_margin="10dp"
                            app:labelText="Goal Description:"
                            android:visibility="invisible" >

                            <com.developer.mtextfield.ExtendedEditText
                                android:id="@+id/aexpanded_active_goal_card_edit_description_edit_text"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center_horizontal"/>

                        </com.developer.mtextfield.TextFieldBoxes>

                        <LinearLayout
                            android:id="@+id/aexpanded_active_goal_card_sub_goals_label_container"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@id/aexpanded_active_goal_card_description"
                            android:layout_centerHorizontal="true"
                            android:layout_margin="5dp"
                            android:gravity="center_vertical"
                            android:orientation="horizontal"
                            android:weightSum="14">

                            <View
                                android:id="@+id/aexpanded_active_goal_card_sub_goal_label_left"
                                android:layout_width="0dp"
                                android:layout_height="3dp"
                                android:layout_weight="4"
                                android:background="@color/light_gray" />

                            <TextView
                                android:id="@+id/aexpanded_active_goal_card_sub_goals_label"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_margin="5dp"
                                android:layout_weight="6"
                                android:gravity="center"
                                android:text="SubGoals"
                                android:textColor="#5A5A5A"
                                android:textSize="25sp"
                                android:textStyle="bold" />

                            <View
                                android:id="@+id/aexpanded_active_goal_card_sub_goal_label_right"
                                android:layout_width="0dp"
                                android:layout_height="3dp"
                                android:layout_weight="4"
                                android:background="@color/light_gray" />

                        </LinearLayout>

                        <RelativeLayout
                            android:id="@+id/aexpanded_active_goal_card_sub_goals_container"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_below="@+id/aexpanded_active_goal_card_sub_goals_label_container"
                            android:layout_centerHorizontal="true"
                            android:layout_margin="10dp"
                            android:animateLayoutChanges="true"
                            android:elevation="15dp"
                            android:gravity="center">

                            <androidx.recyclerview.widget.RecyclerView
                                android:id="@+id/aexpanded_active_goal_card_sub_goals_recycler_view"
                                android:layout_width="match_parent"
                                android:layout_height="100dp"
                                android:nestedScrollingEnabled="true" />

                        </RelativeLayout>

                    </RelativeLayout>

                </RelativeLayout>

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/edit_panel"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="4dp"
                    android:layout_below="@id/aroot_view_per_active_goal"
                    android:visibility="gone">

                    <RelativeLayout
                        android:id="@+id/edit_delete_button"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="15dp"
                        android:elevation="8dp"
                        android:padding="15dp"
                        android:clickable="true"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintBottom_toBottomOf="parent"
                        android:focusable="true"
                        android:background="@drawable/delete_goal_button_background">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textAllCaps="false"
                            android:textColor="@android:color/white"
                            android:text="@string/active_goal_item_delete_button_text"/>

                    </RelativeLayout>

                    <RelativeLayout
                        android:id="@+id/edit_cancel_button"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="15dp"
                        android:elevation="8dp"
                        android:padding="15dp"
                        android:clickable="true"
                        app:layout_constraintEnd_toStartOf="@id/edit_save_button"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintBottom_toBottomOf="parent"
                        android:focusable="true"
                        android:background="@drawable/cancel_edits_button_background">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textAllCaps="false"
                            android:textColor="@android:color/white"
                            android:text="@string/active_goal_item_cancel_edits_button_text"/>

                    </RelativeLayout>

                    <RelativeLayout
                        android:id="@+id/edit_save_button"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="15dp"
                        android:elevation="8dp"
                        android:padding="15dp"
                        android:clickable="true"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintBottom_toBottomOf="parent"
                        android:focusable="true"
                        android:background="@drawable/save_edits_button_background">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textAllCaps="false"
                            android:textColor="@android:color/white"
                            android:text="@string/active_goal_item_save_edits_button_text"/>

                    </RelativeLayout>

                </androidx.constraintlayout.widget.ConstraintLayout>

            </RelativeLayout>

        </androidx.cardview.widget.CardView>


    </FrameLayout>

    <com.github.mmin18.widget.RealtimeBlurView
        android:id="@+id/ablur"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/cardHolder"
        android:layout_alignBottom="@id/cardHolder"
        app:realtimeBlurRadius="20dp"
        app:realtimeOverlayColor="#8000"
        android:visibility="invisible"/>


</RelativeLayout>