Superunknown
Superunknown

Reputation: 501

Android Layout Issue

Hi I'm having a daft problem with my android application.

Currently it looks like this:

enter image description here

Is there a way of making the button go to the bottom in the middle? I've tried messing around but same effect. Also tried changing the fill_parent/wrap_content, relative/linear layouts and gravities.

This is the screenshot of the .xml file

enter image description here

many thanks.

Upvotes: 0

Views: 370

Answers (3)

Patrick Kafka
Patrick Kafka

Reputation: 9902

There are a couple things you can do to get this, with the relative layout you're using this would work. Add these lines to your button section

android:layout_below="@+id/android:empty"
android:layout_alignParentBottom="true"
android:layout_alignParentCenter="true"

Upvotes: 1

Paciotti
Paciotti

Reputation: 35

May be you want to use a linear layout instead of the relative one... With the LinearLayout you can place your item without thinking on their relative position. You can place a vertical linear layout and inside it another layout for the list of reminders.

<LinearLayout android:orientation="vertical">

<ListView android:width="fill_parent"android:weight="2" />
<Button android:width="wrap_content" android:weight="1" />

</LinearLayout>

With weight option, you can choose to make the Button to be painted before the ListView.

EDIT: Reading other answers, I'm considering if you really need a RelativeLayout to place a button under a listview. I think you should learn how to handle simple view before to start using something more complex. If LinearLayout solve your problem, why don't use it? This is a personal observation...

Upvotes: 0

Aleadam
Aleadam

Reputation: 40401

Add these two attributes to your Button

android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"

and these one to your textview:

android:layout_above="@id/insertion"
android:layout_height="fill_parent"

Read the API reference here: http://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html

Upvotes: 0

Related Questions