2

Mylayout由一个ScrollView包含所有内容的 a 组成。在某些时候,我需要在ScrollView 顶部(上方)View的屏幕底部显示 a (所以在 ScrollView的后面),这样我就可以上下滚动屏幕,同时它仍然会粘在设备的屏幕底部。请教大家如何做这样的. 谢谢你。ScrollViewViewViewlayout

4

3 回答 3

4

如果您希望滚动视图位于视图后面,可以这样做:

问题的部分代码副本)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:id="@+id/RelativeLayout1">

        <ScrollView android:id="@+id/scrollView"  
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
        </ScrollView>

        <View android:id="@+id/bottomView" 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:layout_alignParentBottom="true"
            android:visibility="gone">>
        </View>
</RelativeLayout>

滚动视图现在将扩展到 View 元素之外。

于 2012-11-29T15:24:06.603 回答
1

您可以创建两个片段并使用权重属性来分配空间。顶部的片段将承载您的根滚动视图,底部的片段将具有视图。

于 2012-11-29T15:23:58.587 回答
0

好的两个选项,第一个:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<View
    android:id="@+id/myView"
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:layout_alignParentBottom="true" />

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@id/myView" />

</RelativeLayout>

这样,您ScrollView将永远高于您的View. 但似乎您希望 ScrollView 填满整个屏幕,而 View “隐藏” SV. 所以检查这段代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

 <ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"/>

 <View
    android:id="@+id/myView"
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:layout_alignParentBottom="true" />

</RelativeLayout>
于 2012-11-29T15:43:39.447 回答