Android 将相对布局设置为与滚动视图相同的高度
我有一个活动,有几个不同的布局/滚动视图等。目前,我的滚动视图设置为固定高度。但即使我已经将布局设置为与滚动视图相同的高度,滚动视图仍会切断屏幕底部的水平滚动视图 有人能解释一下如何使布局高度与滚动视图相同吗 我的最终目标是:将图像固定在屏幕顶部,水平滚动视图固定在屏幕底部,滚动视图占据剩余空间 以下是我的XML:Android 将相对布局设置为与滚动视图相同的高度,android,android-layout,Android,Android Layout,我有一个活动,有几个不同的布局/滚动视图等。目前,我的滚动视图设置为固定高度。但即使我已经将布局设置为与滚动视图相同的高度,滚动视图仍会切断屏幕底部的水平滚动视图 有人能解释一下如何使布局高度与滚动视图相同吗 我的最终目标是:将图像固定在屏幕顶部,水平滚动视图固定在屏幕底部,滚动视图占据剩余空间 以下是我的XML: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="ht
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".HomeScreen"
android:weightSum="1">
<RelativeLayout
android:id="@+id/RelLayoutTitleImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<ImageView
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:id="@+id/titleimage"
android:src="@drawable/saferroadsshellharbourtitle"
android:layout_weight="0.08" />
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="272dp"
android:id="@+id/scrollView"
android:layout_gravity="center"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="272dp"
android:orientation="vertical">
<ImageButton
android:layout_width="fill_parent"
android:layout_height="100dp"
android:id="@+id/btn_Old_logo"
android:clickable="true"
android:src="@drawable/oldlogomenu"/>
<ImageButton
android:layout_width="fill_parent"
android:layout_height="100dp"
android:id="@+id/btn_report_a_hazard"
android:layout_below="@+id/btn_Old_logo"
android:clickable="true"
android:src="@drawable/reportahazardmenu"/>
<ImageButton
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_below="@+id/btn_report_a_hazard"
android:id="@+id/btn_Council_Website"
android:clickable="true"
android:src="@drawable/councilwebsitemenu"/>
<ImageButton
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_below="@+id/btn_Council_Website"
android:id="@+id/btn_dob_in_a_hoon"
android:clickable="true"
android:src="@drawable/dobinahoonmenu"/>
</RelativeLayout>
</ScrollView>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/horizontalScrollView2"
android:layout_gravity="bottom">
<RelativeLayout
android:orientation="horizontal"
android:layout_width="120dp"
android:layout_height="90dp"
android:gravity="bottom"
>
<ImageButton
android:layout_width="120dp"
android:layout_height="90dp"
android:id="@+id/facebook"
android:layout_gravity="center_horizontal"
android:clickable="true"
android:src="@drawable/facebookbutton"
android:scaleType="fitCenter"/>
<ImageButton
android:layout_width="120dp"
android:layout_height="90dp"
android:layout_toRightOf="@+id/facebook"
android:id="@+id/twitter"
android:layout_gravity="center_horizontal"
android:clickable="true"
android:src="@drawable/scclogoold"
android:scaleType="fitCenter"/>
<ImageButton
android:layout_width="120dp"
android:layout_height="90dp"
android:layout_toRightOf="@+id/twitter"
android:id="@+id/contact"
android:layout_gravity="center_horizontal"
android:clickable="true"
android:src="@drawable/contactbutton"
android:scaleType="fitCenter"/>
</RelativeLayout>
</HorizontalScrollView>
试试看
android:layout\u height=“match\u parent”
我假设您的ScrollView可以设置为
layout\u height=wrap\u content
@emersso,如果我这样做,它不会完全阻止屏幕底部的水平滚动视图。是的,您完全正确。我应该说“ScrollView中的RelativeLayout”。@emersso这是正确的想法,但我希望它是另一场战争-即我希望相对布局高度与ScrollView高度相同尝试设置相对布局高度以匹配父级,如果父级具有设置的高度?您可以使用线性布局而不是相对布局,并包括图像按钮的权重。现在,底部的整个水平滚动视图已被垂直滚动视图覆盖。没关系,我使用了错误的视图。你的回答是正确的。谢谢