Reputation: 203
I am using recyclerview and GridLayoutManager to display texts in textView .I want to display these items as shown in image 1 . Requirement of app is enter image description hereIf textview takes 2 lines to display set number of column to 1 else make it 2. I have tried using GridAutoFitLayoutManager.java from below link,but it didn't work. https://gist.github.com/omidraha/af3aa017d4ec06342bdc03c49d4b83b1
As of now I have set number of columns to 2. Below is my code hotAdapter=new HotAdapter(this,hotItems,this); hotRecyclerView.setAdapter(hotAdapter);
GridLayoutManager gridLayoutManager=new GridLayoutManager(this,2);
hotRecyclerView.setLayoutManager(gridLayoutManager);
Upvotes: 2
Views: 1396
Reputation: 567
You can try flexbox layout. After adding flexbox layout to your project then you can set it's direction=row and wrap=wrap.
<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:flexDirection="row"
app:flexWrap="wrap" >
<TextView />
<TextView />
...
</com.google.android.flexbox.FlexboxLayout>
Upvotes: 3