StackOverflow:Horizontal ListView in Android?
http://stackoverflow.com/questions/3240331/horizontal-listview-in-android、
Github上搜索:Horizontal ListView
https://github.com/MeetMe/Android-HorizontalListView
https://github.com/jess-anders/two-way-gridview
https://github.com/lucasr/twoway-view
百度一下:
Android UI开发: 横向ListView(HorizontalListView)及一个简单相册的完整实现
http://blog.csdn.net/yanzi1225627/article/details/21294553
大多数使用HorizontalScrollView(LinearLayout、GridView)布局,根据item数各种计算,都比较复杂。Android 5.0引入RecyclerView(被认为是下一代的ListView),使用它来实现更灵活,比较有名的TwoWayView也正在用RecyclerView重写。
这里使用RecyclerView简单实现一个能够横向水平滑动的ListView。
(1)需要导入android-support-v7-recyclerview.jar
(2)res/layout/recyclerview.xml
<android.support.v7.widget.RecyclerView android:id="@+id/recycler_view" android:scrollbars="vertical" android:layout_width="match_parent" android:layout_height="match_parent"/>
(3)Fragment的实现
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View result = inflater.inflate(R.layout.recyclerview, container, false); recyclerView = (RecyclerView) result.findViewById(R.id.recycler_view); recyclerView.setHasFixedSize(true); int spanCount = 1; // 只显示一行 layoutManager = new StaggeredGridLayoutManager(spanCount, StaggeredGridLayoutManager.HORIZONTAL); recyclerView.setLayoutManager(layoutManager); recyclerView.setAdapter(adapter); return result; }
最终效果图: