This is my code.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:minHeight="1000dp">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="2dp">
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="2dp">
</android.support.v7.widget.CardView>
</LinearLayout>
I set the minHeight of linear layout in xml. But I want to set it programmatically. I have two cards in this linear layout. And I want to set the minHeight on the basis of my two cards height.
You can use View.setMinimumHeight()
check more details on developer.android :
http://developer.android.com/reference/android/view/View.html#setMinimumHeight(int)