I want to have a horizontal RecyclerView that I can insert or remove items from. (我想要一个水平的RecyclerView,可以从中插入或删除项目。) The items should be aligned to the center when the RV width is smaller than the screen's. (当RV宽度小于屏幕宽度时,项目应与中心对齐。)
Note: I cannot use android:layout_width=wrap_content
, as suggested in other questions, since a change in the RV size will cause misbehaving animations (ie items sliding in from "outside the RV" on item removal). (注意:我不能使用android:layout_width=wrap_content
,如其他问题所建议的那样,因为RV大小的更改会导致动画出现异常(即,在移除项目时从“ RV外部”滑入的项目)。)
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
recyclerView.setLayoutManager(layoutManager);
... (...)
Any ideas? (有任何想法吗?)
ask by lea.cotan translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…