Reputation: 534
I need to create a list with 2 columns, every column contain number of views (Image and Text), the problem is that I need to use different height for the images, gridview create list with the same height for every row, I try to create something like that by myself (create container layout with 2 columns and add views using for loop and inflater) the result, app memory gets to his limit something I get out of memory exception, If its not enogth I have to use android:adjustViewBounds="true" for fitting the image to the layout (getting unexpected padding) so also the CPU working harder then expected, I guess adapter should help, we can use adapter without listview or gridview? there is a tool for creating those kind of list?
Upvotes: 0
Views: 164
Reputation: 41
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="2"
/>
<RecyclerView
android:id="leftRecyclerView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<RecyclerView
android:id="rightRecyclerView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</LinearLayout>
Then you can implement these two recyclerviews, they will not depend from each other and they will take both half of the screen.
For every lists you need to display, always use RecyclerViews to not kill your CPU and memory.
Upvotes: 0
Reputation: 133
If I understand it correctly StaggeredGridLayoutManager should do what you need. Make some RecyclerView with your Adapter and use it there. Hope it helps.
Upvotes: 3