添加视图布局底部的滚动型内 [英] Adding view to bottom of layout inside a scrollview
问题描述
所以,我的布局基本上是这样的:
So my layout looks basically like this:
<ScrollView>
<RelativeLayout>
<BunchOfViews/>
<ImageView android:layout_alignParentBottom="true"/>
</RelativeLayout>
</ScrollView>
我有滚动型,这样所有的布局的始终是可见无论屏幕的高度。问题是一个非常高的屏幕上,我还是希望我的ImageView是在底部。不过,滚动型的孩子似乎不具有定义的底部。该视图放置在布局的顶部。我该如何解决这个问题的一种巧妙的方法?
I have the ScrollView so all of the layout always is visible no matter the height of the screen. The problem is that on a very high screen, I still want my imageview to be at the bottom. However, a child of a ScrollView dont seem to have a defined bottom. The View is placed at the top of the layout. How can I solve this problem in a neat way?
干杯,
推荐答案
我碰到了同样的问题。我从来没有找到一个非常讨人喜欢的解决方案,但这里是我做到了。也许别人有更好的办法,我讨厌补充布局,什么也不做。
I ran into the same issue. I never could find a very pleasing solution, but here is how I did it. Maybe someone else has a better way, I hate adding layouts that don't do anything.
我的黑客是添加一个虚拟的LinearLayout在已FILL_PARENT采取了所有的房间,并迫使滚动视图来填充屏幕的滚动型的底部。然后添加任何成分我想是的LinearLayout。
My hack was to add a dummy linearlayout at the bottom of the scrollview that has fill_parent to take up all the room and force the scrollview to fill the screen. Then add whatever component I want to that linearlayout.
下面是我的布局一个做到这一点:
Here is one of my layouts that does this:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="15px" >
<!-- bunch of components here -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/spinner"
android:layout_marginTop="5px"
android:gravity="center_horizontal|bottom"
android:paddingTop="2px" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20px"
android:paddingRight="20px"
android:text="Delete" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
这篇关于添加视图布局底部的滚动型内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!