这是我的代码。以编程方式设置LinearLayout的minHeight
<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>
我在xml中设置线性布局的minHeight。但我想以编程方式设置它。我在这个线性布局中有两张牌。并且我想根据我的两张卡片高度设置minHeight。
可能的d重复[Android:以编程方式设置视图的最小高度](http://stackoverflow.com/questions/16790902/android-set-minimum-height-of-a-view-programmatically) –
@Sanket您是否尝试过我的解决方案 –
@sanky我正在尝试你的解决方案。感谢您的回答 – Sanket