【发布时间】:2020-08-25 11:10:08
【问题描述】:
我有以下布局:
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/cat_card_list_item_card"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
android:minHeight="118dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/effectContainer"
android:orientation="vertical"/>
</com.google.android.material.card.MaterialCardView>
它与对象一起动态添加,如下所示:
Tremolo + 按钮是一个对象,其余是 2 个对象,每个对象都有一个垂直搜索栏。我希望第一个对象的高度为wrap_content,看起来确实如此,其余的则尽可能垂直扩展,因此搜索栏会增长。我已将它们的高度设为“wrap_content”:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/paramWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:id="@+id/paramLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1" />
<TextView
android:id="@+id/curLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle2" />
<TextView
android:id="@+id/minLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption" />
<SeekBar
android:id="@+id/seekBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="10"
android:rotation="270" />
<TextView
android:id="@+id/maxLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption" />
</LinearLayout>
但它们仍然不会增长。我如何让他们尽可能地占据整个空间?
【问题讨论】: