【发布时间】:2017-11-13 03:06:49
【问题描述】:
我有这样的设计: XMLFile1.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/option_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView
android:name="question_paper_scrollView"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</ScrollView>
</RelativeLayout>
XMLFile2.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent">
<include layout=XMLFile1.xml>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:gravity="center|bottom"
android:weightSum="4"/>
</RelativeLayout>
我已根据this 在ScrollView 中设置android:fillViewport="true",并根据this 设置FrameLayout 的minimumHeight()。 FrameLayout 包含测验问题,它们需要可滚动,LinearLayout 包含一组按钮,例如下一个、上一个和清除。我从this 了解到LinearLayout 可以隐藏ScrollView 但我可以看到滚动条。实现的正确方法是什么:给定设计的可滚动问题?
PS:我只能使用LinearLayout,因为我想在屏幕底部设置一组按钮,而使用FrameLayout,因为我从数据库中动态加载测验问题。
解决方案:两个答案的结合。在所有布局中使用 wrap_content,在线性布局中使用用户 layout_below 属性
【问题讨论】:
-
显示布局的属性。
-
@Dabiuteef 添加属性
-
我想这可能会起作用:将 LinearLayout 的 android:layout_height 更改为 wrap_content,并将 android:layout_above="
" 添加到 include 标记中。 -
在两个 xml 文件中设置高度为 wrap_content
-
我必须只为最外层的标签还是所有标签?对于所有标签,它没有帮助,因为 LineaarLayout 包含功能有点像底部标签的按钮
标签: android android-layout scrollview android-scrollview