Android 滚动视图被线性布局阻止
我有一个这样的设计: XMLFile1.xmlAndroid 滚动视图被线性布局阻止,android,android-layout,scrollview,android-scrollview,Android,Android Layout,Scrollview,Android Scrollview,我有一个这样的设计: 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"&
<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>
我已经根据设置了ScrollView
中的android:fillViewport=“true”
,还根据设置了FrameLayout的minimumHeight()
FrameLayout
保存测验问题,这些问题需要可滚动,LinearLayout
由一组按钮组成,如next、previous和clear。我从LinearLayout
中学到可以隐藏滚动视图
,但我可以看到滚动条。实现的正确方法是什么:给定设计的滚动问题?
注:我必须使用LinearLayout
,因为我想在屏幕底部设置一组按钮,并使用FrameLayout
,因为我正在从数据库动态加载测验问题
解决方案:两个答案的组合。在所有布局中使用wrap_content,在线性布局中使用user layout_down属性如果不阻止视图,则可以调用ScrollView的bringToFront()
。
或者调整视图的高度。
您还可以将ScrollView设置为android:layout_below=“@id/includeView”
,如果ScrollView不阻止视图,您可以调用bringToFront()
。
或者调整视图的高度。
您还可以将ScrollView设置为下面的android:layout=“@id/includeView”试试这个,在xml文件中,使用所有布局和视图的高度换行内容,而不是填充父对象或匹配父对象。试试这个,在这两个xml文件中,使用所有布局和视图的高度换行内容,而不是填充父项或匹配父项。显示布局的属性。@Dabiuteef添加属性我想这可能会起作用:将LinearLayout的android:layout高度更改为换行内容,并在上面添加android:Layou=“”要将include tag.set height包装两个xml文件中的内容,我必须仅对最外层的标记或所有标记使用它吗?对于所有标签,它没有帮助,因为LinearLayout包含的按钮功能有点像底部选项卡显示布局的属性。@Dabiutef added attributes我想这可能会起作用:更改LinearLayout的android:layout高度以包装内容,并在上面添加android:layout要将include tag.set height包装两个xml文件中的内容,我必须仅对最外层的标记或所有标记使用它吗?对于所有的标签,它没有帮助,因为LinearLayout包含功能有点像底部选项卡的按钮。当我这样做时,我的框架布局完全隐藏。正如我说的,你应该更改视图高度并将布局设置在下方。当我这样做时,我的框架布局完全隐藏。正如我说的,你应该更改视图高度并设置布局下面的布局线性布局用于按钮,其作用类似于底部选项卡。单击“下一步”,我将一个新问题加载到框架中。当我将LinearLayout的高度设置为包裹内容时,所有按钮都会向上。此外,scrollview仅在按钮之前工作,不会超出按钮下方显示文本的范围。线性布局的方向是什么?水平方向。如果我将其更改为垂直,则按钮将堆叠在其他按钮之上。我对底部选项卡按钮使用了线性布局,如下所示:在xmlfile2中,给一些固定高度的线性布局,给android:layout_alignParentBottom=“true”并删除android:gravity=“center | bottom”抱歉,但通过这样做,所有按钮都会位于屏幕顶部线性布局是针对类似底部选项卡的按钮。单击“下一步”,我将一个新问题加载到框架中。当我将LinearLayout的高度设置为包裹内容时,所有按钮都会向上。此外,scrollview仅在按钮之前工作,不会超出按钮下方显示文本的范围。线性布局的方向是什么?水平方向。如果我将其更改为垂直,则按钮将堆叠在其他按钮之上。我对底部选项卡按钮使用了线性布局,如下所示:在xmlfile2中,给出一些固定高度的线性布局,并给出android:layout_alignParentBottom=“true”并删除android:gravity=“center | bottom”抱歉,但通过这样做,所有按钮都会进入屏幕顶部