RelativeLayout中的Android定位视图
我有以下视图层次结构: 我希望带有嵌套RelativeLayout的ScrollView位于relativeHeader和relativeFooter之间,因为现在它被页脚重叠了。但当我尝试添加android:layout_over=“@id/relativeFooter”时,我得到了一个错误,即没有这样的视图。我做的事情可能有点滑稽。还有那些“嵌套相对论”的东西。但是我怎样才能实现我的目标呢? 以下是xml:RelativeLayout中的Android定位视图,android,android-layout,Android,Android Layout,我有以下视图层次结构: 我希望带有嵌套RelativeLayout的ScrollView位于relativeHeader和relativeFooter之间,因为现在它被页脚重叠了。但当我尝试添加android:layout_over=“@id/relativeFooter”时,我得到了一个错误,即没有这样的视图。我做的事情可能有点滑稽。还有那些“嵌套相对论”的东西。但是我怎样才能实现我的目标呢? 以下是xml: <?xml version="1.0" encoding="utf-8"?&
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/relativeHeader"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/imgMainLogo"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/btnShort"
android:text="@string/btnShortRemove_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
<ScrollView
android:id="@+id/scrollContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/relativeHeader"
android:paddingBottom="5dp">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/tvDetailedTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
/>
<TextView
android:paddingTop="5dp"
android:id="@+id/tvDetailedPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tvDetailedTitle"
/>
<TextView
android:paddingTop="5dp"
android:id="@+id/tvDetailedPhoneTitle"
android:gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="22dp"
android:layout_below="@id/tvDetailedPrice"
/>
<TextView
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:id="@+id/tvDetailedPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tvDetailedPhoneTitle"
/>
<TextView
android:paddingTop="5dp"
android:id="@+id/tvDetailedDescriptionTitle"
android:gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="22dp"
android:layout_below="@id/tvDetailedPhone"
/>
<TextView
android:paddingTop="5dp"
android:paddingLeft="5dp"
android:layout_below="@id/tvDetailedDescriptionTitle"
android:id="@+id/tvDetailedDescription"
android:text="Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Gallery
android:id="@+id/gallery"
android:layout_below="@+id/tvDetailedDescription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
/>
</RelativeLayout>
</ScrollView>
<RelativeLayout
android:id="@+id/relativeFooter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:background="#716D69"
>
<Button
android:id="@+id/btnDetailedEmail"
android:text="@string/btnDetailedEmail_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:width="120dp"
/>
<Button
android:id="@+id/btnDetailedCall"
android:text="@string/btnDetailedCall_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:width="120dp"
/>
</RelativeLayout>
</RelativeLayout>
谢谢,它很管用!但在我看来这很不寻常。秘密是什么?“+”通常在使用新id时使用。在您的例子中,id{relativeFooter}甚至在声明之前就被引用了。另一种方法是简单地重新排列布局,将页脚放在scrollview之前,布局仍将按您希望的方式显示。很好的解释。你应该考虑把这个评论移到你的答案中。
<RelativeLayout
android:id="@id/relativeFooter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:background="#716D69"
>
<ScrollView
android:id="@+id/scrollContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/relativeHeader"
android:layout_above="@+id/relativeFooter"
android:paddingBottom="5dp">