本項目主要listview實現各類版面設計功能,有實現列表的,gridview效果的,有混排效果的等等。
自定義TwoWayView繼承RecyclerView,經過TwoWayView去根據佈局實現到底選擇哪個效果,
本項目來自:https://github.com/lucasr/twoway-view
listview代碼部分:
<org.lucasr.twowayview.widget.TwoWayView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/TwoWayView"
app:twowayview_layoutManager="ListLayoutManager"/>html
實現gradview效果:
<org.lucasr.twowayview.widget.TwoWayView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/TwoWayView"
app:twowayview_layoutManager="GridLayoutManager"
app:twowayview_numColumns="3"
app:twowayview_numRows="3" />android
實現混排效果:
<org.lucasr.twowayview.widget.TwoWayView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/TwoWayView"
app:twowayview_layoutManager="StaggeredGridLayoutManager"
app:twowayview_numColumns="2"
app:twowayview_numRows="2" />git
項目源碼:http://www.itlanbao.com/code/20151023/10000/100592.htmlgithub