内容简介
简单看一下需要实现的效果,如图:
实现步骤
第一步 找准方向
其实就是想好要用recyclerview而不是listview。如果要问我recyclerview是什么的话。。
第二步 开干
首先需要先在xml里放置这么个控件
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg_main">
</android.support.v7.widget.RecyclerView>
这里我加了一个背景,背景也可以在它的父布局加,主要是作为动画的时候下面的颜色(颜色为一种灰色)。
然后,需要编写每个item的布局,这里也非常简单,还是贴一下代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"