Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android:layout_alignParentBottom is ignored when used without explicit layout height as a row in ListView

Tags:

android

layout

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?

like image 544
alexanderblom Avatar asked Mar 26 '10 00:03

alexanderblom


2 Answers

This seems to be a bug in Android itself, see http://code.google.com/p/android/issues/detail?id=1394.

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.

like image 66
alexanderblom Avatar answered Sep 19 '22 18:09

alexanderblom


When you inflate the layout, use inflate(R.layout.whatever, parent, false), where parent is the ListView. If you don't do that (e.g., you pass null for the parent), RelativeLayout gets strange in list rows.

like image 21
CommonsWare Avatar answered Sep 20 '22 18:09

CommonsWare