• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps I need a RecyclerView to WRAP_CONTENT bigger than its parent

Eranot

Lurker
Hello, I need a RecyclerView to WRAP_CONTENT bigger than its parent. Imagine that there is a LinearLayout with 50dp of height and I want a RecyclerView inside it, but its content gonna be bigger than 50dps and I want the RecyclerView just WRAP_CONTENT and be as big as it has to. The problem is that mine just stays at 50dp no matter what I do.

My current code is:

Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_marginBottom="2dp"
    android:background="@drawable/recycle_view_selector"
    android:id="@+id/semestre"
    android:clipChildren="false">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal"
        android:id="@+id/nome">

        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent"
            android:text="Teste"
            android:textAlignment="center"
            android:gravity="center"
            android:background="#e8e8e8"
            android:textSize="20sp"
            android:id="@+id/semestreNome"/>

    </LinearLayout>

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/materias"
        android:clipChildren="false"
        android:clipToPadding="false"
        android:layout_below="@id/nome"/>

</RelativeLayout>

In this case, my RecyclerView stays at 0dp (because my main RelativeLayout is 50dp and my TextView is also 50dp). When my main RelativeLayout is 60dp the RecyclerView stays at 10dp.

In case you are wondering why I need this, its because I'll expand the layout and I have to know how much I need to expand, that why I need to know how bigger is the height of my RecyclerView. Thanks.
 
Back
Top Bottom