How to display recycler view items side by side

后端 未结 4 800
萌比男神i
萌比男神i 2021-01-16 22:38

How can we display RecyclerView items side by side. i tried to do this by using FlowLayoutManager and FlexboxLayoutManager but it is s

相关标签:
4条回答
  • 2021-01-16 23:11

    set orientation of linearlayoutmanager for recyclerview

    LinearLayoutManager layoutManager = LinearLayoutManager(activity,RecyclerView.HORIZONTAL,false)
    
    0 讨论(0)
  • 2021-01-16 23:12

    try this

    setFlexDirection as Row Reverse
    
    0 讨论(0)
  • 2021-01-16 23:13

    Please follow the below code and make your adapter textview wrap content may it will solve your problem.

            RecyclerView recyclerView = (RecyclerView)findViewById(R.id.flex_box_recycler_view);
    
            // Create the FlexboxLayoutMananger, only flexbox library version 0.3.0 or higher support.
            FlexboxLayoutManager flexboxLayoutManager = new FlexboxLayoutManager(getApplicationContext());
    
            // Set flex direction.
            flexboxLayoutManager.setFlexDirection(FlexDirection.ROW);
    
            // Set JustifyContent.
            flexboxLayoutManager.setJustifyContent(JustifyContent.SPACE_AROUND);
            recyclerView.setLayoutManager(flexboxLayoutManager);
    

    Add into xml like this:

    <com.google.android.flexbox.FlexboxLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:flexWrap="wrap"
        app:alignItems="stretch"
        app:alignContent="stretch" >
    
    0 讨论(0)
  • 2021-01-16 23:17

    Use ChipsLayoutManager use following lib helps me to do same

     implementation 'com.beloo.widget:ChipsLayoutManager:0.3.7@aar'
    
    0 讨论(0)
提交回复
热议问题