我有一个最多3行的recyclerview。该房车位于我视图的顶部。在我的片段下面的容器中。当我要滚动片段中的内容并在片段内容的顶部显示rv的所有元素时,我只想使rv的最后一个元素可见。该怎么做?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="2dp"/>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
答案 0 :(得分:0)
首先,您必须在布局中使用nestedscrollview才能正确滚动父布局中的recyclerView和其他视图。
您可以做的第二件事是仅将列表的最后一个元素发送到适配器。
like,
ArrayList<Test> tempList=new ArrayList();
tempList.add(customList.get(customList.size()-1);
其中customList是要作为参数发送到适配器的类数据的类型。
这样您就可以完成工作。