0

I have a layout where I want the ListView to be at the bottom of the screen on every device. On the Android Studio preview it looks fine, but on my device it looks like this:

device

When it should look like this:

device

Code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="1">

    <ImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:id="@+id/imageView"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="65dp"
        android:src="@drawable/test"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Full Name"
        android:id="@+id/textView"
        android:layout_below="@+id/imageView"
        android:layout_centerHorizontal="true"
        android:paddingTop="7dp"
        android:textStyle="bold"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="University"
        android:id="@+id/textView2"
        android:layout_below="@+id/textView"
        android:layout_centerHorizontal="true" />

    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Button"
        android:id="@+id/button"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@+id/textView2" />

    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Button"
        android:id="@+id/button2"
        android:layout_alignTop="@+id/button"
        android:layout_toRightOf="@+id/textView" />

    <ListView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/customList"
        android:layout_below="@+id/textView"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="95dp" />

</RelativeLayout>
user1902535
  • 155
  • 1
  • 3
  • 10
  • Try encapsulating everything except the ListView into a LinearLayout, and set a weight value to the Linear Layout grather than the ListView. And remove the marginTop on the ListView – soynerdito Feb 24 '14 at 02:27
  • 1
    http://stackoverflow.com/questions/2386866/how-to-align-views-at-the-bottom-of-the-screen?rq=1 – karan Feb 24 '14 at 02:40

2 Answers2

2

You should add android:layout_alignParentBottom to your ListView.

abraabra
  • 464
  • 3
  • 10
1

Well take your three button in one layout say yourButtonContainer and you can have listview with property

 android:layout_alignParentBottom="true"

along with the property

android:layout_below="@+id/yourButtonContainer" 
NullPointerException
  • 3,978
  • 4
  • 34
  • 52