question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RecyclerView Height issue

See original GitHub issue

Hi I am using RecyclerView with FlexboxLayoutManager for layoutManager.setFlexDirection(FlexDirection.ROW); RecyclerView height is resctrited to show only 3 rows . this is my layout `<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:paddingTop="@dimen/_25dp">

<TextView
    android:id="@+id/reviews_label"
    style="@style/body1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="@dimen/_10dp"
    android:text="Reviews"
    android:textAllCaps="true"
    android:textColor="@color/dark_gray_color" />


<TextView
    android:id="@+id/rating_count"
    style="@style/caption"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/reviews_label"
    android:layout_marginLeft="@dimen/_10dp"
    android:layout_marginTop="@dimen/_20dp"
    android:layout_toRightOf="@id/rating_layout"
    android:text="Based on 150 ratings"
    android:textColor="@color/dark_gray_color" />

<TextView
    style="@style/small2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/rating_count"
    android:layout_marginLeft="@dimen/_10dp"
    android:layout_marginTop="@dimen/_1dp"
    android:layout_toRightOf="@id/rating_layout"
    android:text="Weighted average based on user credibility on purplle" />

<TextView
    android:id="@+id/pros_label"
    style="@style/caption"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/rating_layout"
    android:layout_marginBottom="@dimen/_10dp"
    android:layout_marginLeft="@dimen/_10dp"
    android:layout_marginTop="@dimen/_20dp"
    android:text="@string/positives"
    android:textColor="@color/forest_green" />

<TextView
    android:id="@+id/tap_to_filter_pros"
    style="@style/small2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/rating_layout"
    android:layout_marginLeft="@dimen/_10dp"
    android:layout_marginTop="@dimen/_22dp"
    android:layout_toRightOf="@id/pros_label"
    android:text="@string/tap_to_filter"
    android:textColor="@color/light_gray_color" />

<android.support.v7.widget.RecyclerView
    android:id="@+id/pros_highlight_recyclerview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/pros_label"
    android:layout_marginLeft="@dimen/_5dp"
    android:nestedScrollingEnabled="false" />

`

This is RecyclerView item layout

<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/highlight_root"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/_5dp">

    <TextView
        android:id="@+id/selected_icon"
        style="@style/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="@dimen/_2dp"
        android:gravity="center"
        android:paddingLeft="@dimen/_5dp"
        android:text="@string/circular_tickbox"
        android:textSize="@dimen/_13dp" />

    <TextView
        android:id="@+id/name"
        style="@style/small"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:paddingBottom="@dimen/_6dp"
        android:paddingRight="@dimen/_13dp"
        android:paddingTop="@dimen/_6dp" />

</com.google.android.flexbox.FlexboxLayout>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
rahuldevanavar91commented, May 30, 2017

if I use layoutManager.setFlexDirection(FlexDirection.COLUMN); this works perfectly.

0reactions
rahuldevanavar91commented, Jun 20, 2017

Yes I excluded,

compile('com.google.android:flexbox:0.3.0-alpha4') {
        transitive = false
        exclude module: 'support-v4'
    }

now the app is crashing java.lang.NoClassDefFoundError: com.google.android.flexbox.FlexboxLayoutManager

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I make WRAP_CONTENT work on a RecyclerView
By commenting height = heightSize; (in the second switch case) I managed to make the height work but only if a TextView child...
Read more >
RecyclerView HEIGHT=WRAP_CONTENT not working ...
A quick fix for this is to migrate the layout to RelativeLayout, define layout_above and layout_below attributes. Height can either be " ...
Read more >
android recyclerview height wrap content - YouTube
android recyclerview height wrap content | recyclerview dynamic height item | recyclerview tutorialHello everyone, in this video you will ...
Read more >
RecyclerView with height set to wrap_content doesn't keep ...
I've attached the sample application. The attached code reproduces the issue where the RecyclerView doesn't show the first item in the list when...
Read more >
RecyclerView layout_width Not Set When Using wrap_content
I add more items to the recyclerView and reproduce the problem. This is because the recyclerView's height is larger than the include layout...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found