一个带时间的相册页面,真小米手机仿小米相册
这个我研究了两天,真要命,昨晚搞出来的。在这里我们用了以下gradle:
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.truizlop.sectionedrecyclerview:library:1.0.0'
第一个是卡片,点了有水波效果,
第 2个是你们懂得看名字就知道,
第3个是安卓官方推荐的处理图片的框架,
第4个是一个带头部分组栏的适配器.
首先你们看到的布局,我们来写:
主布局
时间的item:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.bbg.textalbum.MainActivity"> <android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:id="@+id/RV" android:layout_height="match_parent"> </android.support.v7.widget.RecyclerView> </RelativeLayout>
然后是中间imgview:<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="10dp" android:id="@+id/headTV" android:text="159.8.5" android:gravity="center"/> </LinearLayout>