![enter image description here](https://i.stack.imgur.com/povQR.png)
![enter image description here](https://i.stack.imgur.com/fKbxV.png)
Есть ли способ сохранить другие нерасширенные предметы, расположенные внизу , На втором рисунке элементы смещаются вверх - это нежелательно.
Вот элемент, показанный на рисунках выше.
<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>
Вот родитель макет, в котором содержится представление рециркулятора.
<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>
Вот мой прослушиватель onScroll, который отвечает за отображение или исчезновение массивного текстового представления:
@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;
}
}
Вот мой желаемый вывод. Возможно ли что-то подобное? Первая картинка слева - это то, что я хочу. Второе - это то, что происходит в настоящее время. ![enter image description here](https://i.stack.imgur.com/OpyR6.png)