先看效果
这种效果实现的思路其实很简单,就把要显示的的和要折叠的内容分为两部分,折叠的内容默认为不显示,当点击按钮的时候就把它显示出来,其实难点在于折叠显示的动画,我是直接参考别人的代码的,看了之后其实也并不难,只能说我对api不熟悉;不多bb直接上代码:
首先是布局没什么好说
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_demo"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
RecyclerView子布局
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginLeft="10dp"
android:layout_marginTop=