从 API 16 开始,控件Gallery已被废弃,此时我们可以用RecyclerView实现类似于ViewPager的横向移动。
效果图:
布局文件很简单就一个RecyclerView:
<?xml version="1.0" encoding="utf-8"?> xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.hans.hansrecyclergallery.MainActivity" > android:id="@+id/rv" android:layout_marginTop="200dp" android:layout_width="match_parent&#