android:layout_alignParentBottom在ListView中没有显式布局高度的情况下使用时被忽略 [英] android:layout_alignParentBottom is ignored when used without explicit layout height as a row in ListView
问题描述
当我使用RelativeLayout
并将fill_parent
或wrap_content
作为高度,并指定一个元素:android:layout_alignParentBottom="true"
时,它将被忽略,并在顶部对齐.将RelativeLayout
的高度设置为显式值可以使其起作用.有任何线索吗?
When I use a RelativeLayout
with either fill_parent
or wrap_content
as height and an element which specifies: android:layout_alignParentBottom="true"
it is ignored and it is aligned at the top. Setting the height of the RelativeLayout
to an explicit value makes it work. Any clues?
推荐答案
This seems to be a bug in Android itself, see http://code.google.com/p/android/issues/detail?id=1394.
我通过将RelativeLayout
包裹在FrameLayout
中并将底部对齐的视图作为FrameLayout
的子级和android:layout_gravity="bottom"
来解决此问题.这会阻止您从RelativeLayout
内部引用它,因此您必须解决该问题(例如,使用边距).
I worked around it by wrapping my RelativeLayout
in a FrameLayout
and putting my bottom aligned view as a children of the FrameLayout
with android:layout_gravity="bottom"
. This hinders you from referencing it from within the RelativeLayout
so you'll have to work around that (for example using margins).
如果有人有更好的解决方法,请分享.
If anyone has a better workaround, please share.
这篇关于android:layout_alignParentBottom在ListView中没有显式布局高度的情况下使用时被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!