【发布时间】:2018-04-29 14:14:29
【问题描述】:
我想开发这个设计:
上部布局有一个最大高度,如果超过这个高度:就会显示一个滚动条。并且底部布局有一个最小高度,并且与上部布局的底部对齐
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="5"
android:orientation="vertical">
<RelativeLayout
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/scrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbarStyle="insideInset" >
<TextView android:id="@+id/quest_question_text"
android:padding="5sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rectangle_quest"
style="@style/entry_style"/>
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:layout_weight="3"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/answer_list"/>
</RelativeLayout>
</LinearLayout>
感谢您的宝贵时间!
可能有一种方法可以根据上部布局的大小来设置相对布局的权重。
【问题讨论】:
-
我不确定你想要什么,但如果你需要 50% 是你的最大值,只需使用线性布局并将 weightsum 设置为 2 并使第一个孩子成为具有 0dp 高度和 layoutweight 1 的滚动视图让我知道你是否想要 xml
-
@Xjasz 我想做的就是我画的,代码可能有很多错误
-
我知道你想要什么我不知道如何使用 layout_weight 在视图上设置最小宽度我会测试一些东西并回复你
-
我已回滚您的编辑,因为解决方案应该在他们自己的答案中。请找到它in the revision history 并将其作为自己的答案发布。
标签: android xml layout height max