Strokes
Strokes

Reputation: 217

Move Listview to bottom of view android

Very new to android, so don't bite...

I'm doing the tutorials @thenewboston but am at the stage where I#m doing a bit more exploration on my own than following tutorials.

I'd like to know (whether it's possible or not...) to move a listview down the view/window/screen. Currently I have a list of items in my listview that populate from the top of the view/window/screen downwards. I'd like to confine my listview to the lower half of the screen say..?

I've tried using android:gravity but to no avail...

Anyone any ideas? If I'm not making sense I could post a picture of what I'm looking to achieve...

EDIT: I've hosted a visual description of what I'm looking for http://tinypic.com/view.php?pic=2hn2jaa&s=6. If the first reply fits, the bill then kudos!

Upvotes: 1

Views: 560

Answers (2)

linakis
linakis

Reputation: 1231

You can do this using weights in a linear layout like so:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <View 
        android:id="@+id/empty_screen_space"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:background="#ff0000"
        android:layout_weight="0.4"/>
    <ListView 
        android:id="@+id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:background="#00FF00"
        android:layout_weight="0.6"/>


</LinearLayout>

Upvotes: 1

Tobrun
Tobrun

Reputation: 18381

use a relative layout, on the listview add this: android:layout_alignParentBottom="true"

Upvotes: 2

Related Questions