title: How to set the cardview height programmatically?
body: <p>I am new in android development and I have searched this question, but not getting any solution.I want to ask how to make the <code>cardview</code> with <code>recyclerview</code> divide into three pieces in one screen? <br></p>
  
  <p><img src="https://i.stack.imgur.com/l8yKa.jpg" alt="example"><br></p>
  
  <p>this is my XML</p>
  
  <pre><code>&lt;LinearLayout 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="wrap_content"
  android:layout_margin="1dp"
  android:orientation="vertical"&gt;
  
  &lt;android.support.v7.widget.CardView
      android:layout_width="match_parent"
      android:id="@+id/card"
      android:layout_height="250dp"
      app:cardCornerRadius="4dp"
      app:cardElevation="1dp"
      app:cardMaxElevation="2dp"&gt;
  
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;com.github.siyamed.shapeimageview.RoundedImageView
              android:id="@+id/image_view"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_alignParentStart="true"
              android:layout_alignParentTop="true"
              android:scaleType="centerCrop"
              android:src="@drawable/ic_launcher_background" /&gt;
  
      &lt;/RelativeLayout&gt;
  &lt;/android.support.v7.widget.CardView&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>and here is the code I try in Activity</p>
  
  <pre><code>View rootLayout = findViewById(R.id.root_layout);
      double height =rootLayout.getLayoutParams().height/3.0;
      CardView card= (CardView)findViewById(R.id.card);
      CardView.LayoutParams layoutParams= (CardView.LayoutParams) card.getLayoutParams();
      layoutParams.height=(int)height;
      layoutParams.width=MATCH_PARENT;
  </code></pre>
  
  <p>Thanks.</p>