title: Android Dev Set the height of a card view as dynamic
body: <p>Hi everyone I am developing an activity that displays the posts of a user and I will use FirebaseRecyclerAdapter and LayoutInflater for the backend part. I'm trying to create the post layout like this:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.cardview.widget.CardView
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      android:orientation=&quot;vertical&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;400dp&quot;
      android:elevation=&quot;20dp&quot;
      android:layout_marginTop=&quot;15dp&quot;
      android:layout_marginRight=&quot;25dp&quot;
      android:layout_marginLeft=&quot;25dp&quot;
      android:backgroundTint=&quot;@color/def2&quot;
  
      &gt;
  
      &lt;RelativeLayout
          android:id=&quot;@+id/card_view&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;&gt;
  
          &lt;androidx.cardview.widget.CardView
              android:id=&quot;@+id/crd_v&quot;
              android:layout_width=&quot;40dp&quot;
              android:layout_height=&quot;40dp&quot;
              android:layout_marginLeft=&quot;10dp&quot;
              android:innerRadius=&quot;0dp&quot;
              android:shape=&quot;ring&quot;
              android:thicknessRatio=&quot;1.9&quot;
              app:cardCornerRadius=&quot;80dp&quot;
              android:layout_marginTop=&quot;10dp&quot;
  
              &gt;
  
              &lt;ImageView
                  android:id=&quot;@+id/img_profilomain&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;match_parent&quot;
  
                  android:layout_alignParentTop=&quot;true&quot;
                  android:layout_centerHorizontal=&quot;true&quot;
                  android:backgroundTint=&quot;@color/white&quot;
                  android:scaleType=&quot;centerCrop&quot;
  
  
                  /&gt;
          &lt;/androidx.cardview.widget.CardView&gt;
  
  
  
          &lt;TextView
              android:id=&quot;@+id/name_text&quot;
              android:layout_width=&quot;145dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginLeft=&quot;25dp&quot;
              android:layout_marginTop=&quot;20dp&quot;
  
              android:text=&quot;Nome Utente&quot;
              android:textAlignment=&quot;center&quot;
              android:textColor=&quot;@color/black&quot;
              android:textSize=&quot;13dp&quot;
              android:visibility=&quot;visible&quot;
  
              /&gt;
  
  
  
  
      &lt;/RelativeLayout&gt;
  
      &lt;TextView
          android:id=&quot;@+id/textView8&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;Titolo&quot;
          android:layout_marginTop=&quot;53dp&quot;
          android:textSize=&quot;15dp&quot;
          android:textColor=&quot;@color/black&quot;
          android:layout_marginLeft=&quot;10dp&quot;
  
  
          /&gt;
  
      &lt;RelativeLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;80dp&quot;
          &gt;
  
       &lt;ImageView
          android:id=&quot;@+id/imageView3&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;300dp&quot;
          app:srcCompat=&quot;@color/white&quot;
          android:layout_marginBottom=&quot;70dp&quot;/&gt;
  
          &lt;TextView
              android:id=&quot;@+id/txt_like&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:text=&quot;0&quot;
              android:layout_marginTop=&quot;254dp&quot;
              android:textSize=&quot;13dp&quot;
              android:textColor=&quot;@color/black&quot;
              android:layout_marginLeft=&quot;20dp&quot;
  
  
  
  
              /&gt;
  
          &lt;ImageView
              android:id=&quot;@+id/imageView4&quot;
              android:layout_width=&quot;13dp&quot;
              android:layout_height=&quot;14dp&quot;
              app:srcCompat=&quot;@drawable/poplike&quot;
              android:layout_marginTop=&quot;256dp&quot;
  
              /&gt;
          &lt;TextView
              android:id=&quot;@+id/textView15&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:text=&quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut hendrerit lacus enim, nec placerat velit fringilla non. Nullam eleifend vestibulum bibendum. Etiam aliquam massa eget rutrum elementum. Vivamus sit amet enim molestie, aliquet quam et, mollis risus. Praesent lacinia congue purus, sed dignissim dui pellentesque et. In hac habitasse platea dictumst. Mauris eget suscipit risus, in egestas ante. Mauris rhoncus quam vel velit volutpat, varius varius metus gravida. Aenean vel placerat turpis. Aenean id erat elementum, porttitor diam et, placerat lorem. Maecenas efficitur, sapien accumsan aliquam blandit, odio velit fermentum enim, eu egestas tortor mauris sit amet diam. Duis porta congue tellus, sed interdum ex suscipit id. Proin nec ex sem. Curabitur bibendum, magna vel dictum vulputate, odio nulla sollicitudin libero, posuere maximus libero nibh non ligula.&quot;
              android:layout_marginTop=&quot;268dp&quot;
              android:textColor=&quot;#333333&quot;
              app:autoSizeTextType=&quot;uniform&quot;
              app:autoSizeMinTextSize=&quot;12sp&quot;
              app:autoSizeMaxTextSize=&quot;100sp&quot;
              app:autoSizeStepGranularity=&quot;2sp&quot;
              /&gt;
  
      &lt;/RelativeLayout&gt;
  
  &lt;/androidx.cardview.widget.CardView&gt;
  </code></pre>
  <p>This is the result of the previous code:</p>
  <p><a href="https://i.stack.imgur.com/EAvaj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EAvaj.png" alt="result" /></a></p>
  <p>However as you can see the text (textview15) is cut from the height of the parent card view. I was wondering if there was a way (preferably from xml and not from java code) to match the height of the parent cardview with the height of the textview15. Anyone have an idea to help me?</p>