问题出在这里:我想放置一个动态高度的视图,该视图将在运行时根据两个视图之间的宽度(我们称之为中心视图)进行计算。棘手的部分是顶视图和底视图应调整其高度以适应中心视图测量和布局后留下的空间,并且它们的高度不应小于minHeight。我设法将所有三个视图放在垂直线性布局中,其中顶部和底部的权重= 1,中心视图是一些固定的高度,但是当中心视图高度变得大于某个值时,它会覆盖顶部和底部视图以及它们的minHeight参数被忽略了。这是布局的一部分,希望它有所帮助:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/topLinearLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:minHeight="84dp"
android:orientation="horizontal" >
<!-- some content here -->
</LinearLayout>
<View
android:id="@+id/centerView"
android:layout_width="match_parent"
android:layout_height="300dp" />
<LinearLayout
android:id="@+id/BottomLinearLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:minHeight="62dp"
android:orientation="horizontal" >
<!-- some content here -->
</LinearLayout>
</LinearLayout>
答案 0 :(得分:0)
通过将中心视图的高度限制为windowHeight - (minHeight1 + minHeight2)来解决它,因为minHeight1和minHeight2是已知常量。如果高度小于windowHeight - (minHeight1 + minHeight2),线性布局没问题