File tree Expand file tree Collapse file tree
app/src/main/java/com/xiaofeng/androidlibs Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,16 +34,29 @@ Single item per line
3434``` java
3535recyclerView. setLayoutManager(new FlowLayoutManager (). singleItemPerLine());
3636```
37+
38+ ``` kotlin
39+ recyclerView.setLayoutManager(FlowLayoutManager ().singleItemPerLine())
40+ ```
41+
3742or x items per line
3843``` java
3944recyclerView. setLayoutManager(new FlowLayoutManager (). maxItemsPerLine(x));
4045```
4146
47+ ``` kotlin
48+ recyclerView.setLayoutManager(FlowLayoutManager ().maxItemsPerLine(x))
49+ ```
50+
4251to remove Item per line limitation
4352``` java
4453((FlowLayoutManager )recyclerView. getLayoutManager()). removeItemPerLineLimit();
4554```
4655
56+ ``` kotlin
57+ (recyclerView.getLayoutManager() as FlowLayoutManager ).removeItemPerLineLimit()
58+ ```
59+
4760Auto measurement
4861---
4962``` java
@@ -52,11 +65,20 @@ flowLayoutManager.setAutoMeasureEnabled(true);
5265recyclerView. setLayoutManager(flowLayoutManager);
5366```
5467
68+ ``` kotlin
69+ flowLayoutManager = FlowLayoutManager ()
70+ flowLayoutManager.setAutoMeasureEnabled(true )
71+ recyclerView.setLayoutManager(flowLayoutManager)
72+ ```
73+
5574Alignment
5675---
5776``` java
5877recyclerView. setLayoutManager(new FlowLayoutManager (). setAlignment(Alignment . LEFT ));
5978```
79+ ``` kotlin
80+ recyclerView.setLayoutManager(FlowLayoutManager ().setAlignment(Alignment .LEFT ))
81+ ```
6082Alignment could be LEFT, CENTER or RIGHT.
6183
6284## Credits
Original file line number Diff line number Diff line change 22
33import java .util .ArrayList ;
44import java .util .List ;
5- import java .util .Random ;
65
76/**
87 * Utility for demo item listWords
98 */
109public class DemoUtil {
11- private static final Random random = new Random ();
12- private static final String STRING_BASE = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
1310
1411 public static List <String > listWords () {
1512 ArrayList <String > result = new ArrayList <>();
Original file line number Diff line number Diff line change @@ -35,7 +35,6 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
3535
3636 recyclerView .setLayoutManager (flowLayoutManager );
3737 recyclerView .getAdapter ().notifyDataSetChanged ();
38- recyclerView .addItemDecoration (itemDecoration );
3938
4039 return true ;
4140 case R .id .navigation_center :
@@ -44,7 +43,6 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
4443
4544 recyclerView .setLayoutManager (flowLayoutManager );
4645 recyclerView .getAdapter ().notifyDataSetChanged ();
47- recyclerView .addItemDecoration (itemDecoration );
4846
4947 return true ;
5048 case R .id .navigation_rigth :
@@ -53,7 +51,6 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
5351
5452 recyclerView .setLayoutManager (flowLayoutManager );
5553 recyclerView .getAdapter ().notifyDataSetChanged ();
56- recyclerView .addItemDecoration (itemDecoration );
5754
5855 return true ;
5956 }
You can’t perform that action at this time.
0 commit comments