在ScrollView中向布局底部添加视图

79
我的布局基本上看起来像这样:
<ScrollView>
    <RelativeLayout>
        <BunchOfViews/>
        <ImageView android:layout_alignParentBottom="true"/>
    </RelativeLayout>
</ScrollView>

我有一个ScrollView,所以无论屏幕的高度如何,整个布局始终可见。问题是,在非常高的屏幕上,我仍然希望我的ImageView在底部。但是,ScrollView的子项似乎没有定义底部。该View位于布局顶部。有什么简洁的方法可以解决这个问题?

11个回答

0

来自:http://code.google.com/p/k9mail/source/browse/k9mail/trunk/res/layout/account_setup_basics.xml?r=1314

这应该会对你有所帮助:

<RelativeLayout
        android:layout_marginTop="-45dip" 
        android:padding="0dip"
        android:layout_alignParentBottom="true"
        android:gravity="bottom|right" 
        android:background="@android:drawable/bottom_bar"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent">
        <Button
            android:id="@+id/manual_setup"
            android:text="@string/account_setup_basics_manual_setup_action"
            android:minWidth="@dimen/button_minWidth"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_marginBottom="-4dip" 
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="false" 
            />
        <Button
            android:id="@+id/next"
            android:text="@string/next_action"
            android:minWidth="@dimen/button_minWidth"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:drawableRight="@drawable/button_indicator_next"
            android:layout_marginBottom="-4dip" 
            android:layout_alignParentRight="true"
            android:layout_centerVertical="false" 
            />
    </RelativeLayout>

对不起,但我认为我没有表达清楚。我仍然希望imageview是scrollview的一部分,就像我的当前布局一样。它应该在scrollview的底部,如果scrollview比屏幕短,则imageview仍应在屏幕底部。 - pgsandstrom
还有,我不太明白在像素数上使用负数的影响。我从未使用过这些。也许我只是没有理解你想说什么。如果是这样,请详细说明一下吧:P 谢谢。 - pgsandstrom
1
如果您的内容不填满屏幕,我不明白为什么需要scrollview。在视图上使用android:gravity="bottom|right"应该将其放置在底部。负值可能旨在削减按钮布局内的过度填充。 - Pentium10

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接