Android 当项目展开时,如何将所有项目绑定到回收器视图的底部?

Android 当项目展开时,如何将所有项目绑定到回收器视图的底部?,android,android-recyclerview,Android,Android Recyclerview,是否有办法将其他未展开的项目保留在底部。在第二张图中,项目向上移动到顶部——这是不需要的 这是上图中显示的项目 <LinearLayout 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

是否有办法将其他未展开的项目保留在底部。在第二张图中,项目向上移动到顶部——这是不需要的

这是上图中显示的项目

<LinearLayout 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:orientation="vertical"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:padding="10dp"
    android:layout_margin="10dp"
    android:clickable="true"
    android:focusable="true"
    android:id="@+id/item_life_event_id"
    android:background="@color/colorAccent"
    android:layout_gravity="bottom">



    <androidx.cardview.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:cardCornerRadius="30dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="600dp"
            android:orientation="horizontal"
            android:id="@+id/massive_text_view"
            android:visibility="gone">


            <TextView
                android:id="@+id/textViewEventDate"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="5"
                android:text="TextView" />

            <ImageView
                android:id="@+id/imageEventNotice"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                tools:srcCompat="@tools:sample/avatars" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/imageViewEventIcon"
                android:layout_width="40dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                tools:srcCompat="@tools:sample/avatars" />

            <TextView
                android:id="@+id/textViewEventTitle"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="5"
                android:text="TextView" />
        </LinearLayout>
    </androidx.cardview.widget.CardView>


</LinearLayout>
这是我想要的输出。这样的事情可能吗?左边的第一张照片是我想要的。第二个是目前发生的情况。

请将您的XML文件代码共享为well@KaranMehta我已经添加了XML和负责扩展项的方法。@jasonp您到底想要什么作为输出请添加ss您到底想要什么need@Wini添加的图片是否有助于支持/澄清我之前为所需输出编写的内容?感谢您对此感兴趣。@Wini我想我可以通过使用压缩动画/缩放开始项目,然后滚动到所选项目时,它将增长到其完整/正常/100%缩放大小来解决此问题。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="bottom">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_weight="99">

        <Button
            android:id="@+id/buttonAdd"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Add"
            />

        <Button
            android:id="@+id/buttonDelete"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Remove" />

        <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Edit" />
    </LinearLayout>

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:layout_weight="1"
        android:focusable="true"
        android:orientation="horizontal"
        tools:listitem="@layout/item" />


</LinearLayout>
@Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);

                int centerPos = layoutManager.findFirstCompletelyVisibleItemPosition();
                View centerView = lifeTimelineRV.getLayoutManager().findViewByPosition(centerPos);

                if (prevCenterPos != centerPos) {
                    // dehighlight the previously highlighted view
                    View prevView = lifeTimelineRV.getLayoutManager().findViewByPosition(prevCenterPos);
                    if (prevView != null) {
                        View previousView = prevView.findViewById(R.id.item_life_event_id);
                        previousView.setSelected(false);
                        previousView.findViewById(R.id.massive_text_view).setVisibility(View.GONE);
                        Log.d(TAG, "onScrolled: not focused" + prevCenterPos);
                        // run scale animation and make it bigger
//                        Animation anim = AnimationUtils.loadAnimation(getContext(), R.anim.scale_out_item);
//                        previousView.startAnimation(anim);
//                        anim.setFillAfter(true);


                    }

                    // highlight view in the middle
                    if (centerView != null) {
                        View currentView = centerView.findViewById(R.id.item_life_event_id);
                        currentView.setSelected(true);
                        Log.d(TAG, "onScrolled: focused" + centerPos);
                        currentView.findViewById(R.id.massive_text_view).setVisibility(View.VISIBLE);
                        // run scale animation and make it smaller
//                        Animation anim = AnimationUtils.loadAnimation(getContext(), R.anim.scale_in_item);
//                        centerView.startAnimation(anim);
//                        anim.setFillAfter(true);
                    }


                    prevCenterPos = centerPos;
                }
            }