0

UPDATE: Thanks everyone for your help, layout_weight is what I was after.

I am currently working on my first android project in java. I am trying to use a linearlayout which has a listview spanning most of the page but has a load more button at the bottom of the app.

This is what it SHOULD look like and is what is previewed to me in Eclipse Previewed in Eclipse

and this is what is happening when I actually run the application

When running the application

The button for some reason is moved a lot higher then I would like, I would like it to stick to the bottom of the page and have the listview take up the rest of the screen...

Here is my layout xml...

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000000">

    <ListView
        android:id="@+id/listview"
        android:layout_width="fill_parent"
        android:layout_height="434dp"
        android:maxHeight="434dp"
        android:minHeight="434dp"
        android:background="#000000" >
    </ListView>

    <Button
        android:id="@+id/button1"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="fill_parent"
        android:layout_height="27dp"
        android:maxHeight="27dp"
        android:text="Load More..."
        android:textSize="@dimen/dp12" />

</LinearLayout>

So my question is,

What have I done wrong or not done at all which is required to keep the button at the bottom of the page?

Thanks.

user2307545
  • 165
  • 1
  • 1
  • 7

2 Answers2

0

It looks like you are setting up the layout using dp measurements. Try using the weight attribute instead. It should do what you want and scale nicely.

http://www.chess-ix.com/blog/the-use-of-layout_weight-with-android-layouts/

What does android:layout_weight mean?

Good Luck!

Community
  • 1
  • 1
Shmuel
  • 3,916
  • 2
  • 27
  • 45
0
<ListView
    android:id="@+id/listview"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="1.00"
    android:background="#000000" >
</ListView>

<Button
    android:id="@+id/button1"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="fill_parent"
    android:layout_height="27dp"
    android:maxHeight="27dp"
    android:text="Load More..."
    android:textSize="@dimen/dp12" />
Gina
  • 902
  • 8
  • 15