有关RecyclerView的一些细节

来源:互联网 发布:济南用友软件 编辑:程序博客网 时间:2024/05/14 04:42
如果想给RecyclerView增加头布局的话,首先:导包compile 'com.bartoszlipinski.recyclerviewheader:library:1.2.0'compile 'com.android.support:recyclerview-v7:25.1.0'在设置了适配器以后, RecyclerViewHeader header = (RecyclerViewHeader) findViewById(R.id.rch);        header.attachTo(mRecyclerView,true);在布局文件中:<android.support.v7.widget.RecyclerView        android:layout_below="@id/rl"        android:id="@+id/rv_list"        android:layout_width="match_parent"        android:layout_height="match_parent"/>    <com.bartoszlipinski.recyclerviewheader.RecyclerViewHeader        android:id="@+id/rch"        android:layout_width="match_parent"        android:layout_height="100dp">        <ImageView            android:background="#ff00"            android:id="@+id/headimg1"            android:layout_width="match_parent"            android:layout_height="match_parent" />    </com.bartoszlipinski.recyclerviewheader.RecyclerViewHeader>
0 0