Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aligning Android Button To Bottom in RelativeLayout?

I'm trying to align a button to the bottom right and bottom left of my screen, using a RelativeLayout. I want to do this to keep the same relative layout across different screen sizes. Currently, the buttons on my screen move up/down depending on the resolution of the screen. 320x480 puts the buttons higher on the screen versus 480x800. I'm trying to get my screens to look the same between the two sizes.

like image 1000
MobiKnow Avatar asked Jan 12 '11 21:01

MobiKnow


People also ask

How do you place a button at the bottom of the screen in android?

From Settings, go to System, Gestures, and then tap System Navigation. Gesture navigation will be selected by default, but you can tap 3-button navigation to make buttons appear at the bottom of your screen.

How do you put a button at the bottom of a linear layout?

If you want to add Buttons to the bottom of your android layout XML file you can achieve it using attribute layout_gravity on LinearLayout or TableRow layout. Below your Parent Layout tag add a LinearLayout or TableRow with attribute android:layout_gravity="bottom".

What is the default placement of objects in a RelativeLayout?

By default, all child views are drawn at the top-left of the layout, so you must define the position of each view using the various layout properties available from RelativeLayout.


1 Answers

I know this is an old thread but it shows up at the top of search results so I figure it can't hurt to confirm that

android:layout_alignParentBottom="true"  

worked for me in RelativeLayout.

like image 102
Casey Murray Avatar answered Oct 11 '22 05:10

Casey Murray