Position ListView Below Buttons - android

I have a ListView that is appearing behind two buttons. I'd like the ListView to fill the area below the buttons. I've tried the solutions in this link:
Android Layout with ListView and Buttons and Listview with button below not working properly . However, it is not working. Can you tell me how to keep theListView below the buttons?
Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0"
>
<ListView
android:id="#+id/listview"
android:layout_width="fill_parent"
android:layout_below="#id/layoutButtons"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:weightSum=".50" />
<LinearLayout
android:id="#+id/layoutButtons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0" >
<Button
android:id="#+id/btnLogout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".70"
android:text="left" />
<Button
android:id="#+id/btnMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".30"
android:text="right" />
</LinearLayout>
</RelativeLayout>

Try the following:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:id="#+id/layoutButtons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/btnLogout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".70"
android:text="left" />
<Button
android:id="#+id/btnMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".30"
android:text="right" />
</LinearLayout>
<ListView
android:id="#+id/listview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
Hope this helps.

You can add the buttons in the header of the listview:
Create a layout with the buttons
listview_header.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layoutButtons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0" >
<Button
android:id="#+id/btnLogout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".70"
android:text="left" />
<Button
android:id="#+id/btnMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".30"
android:text="right" />
</LinearLayout>
Declare views:
private ListView listView;
private ViewGroup mListHeaderView;
onCreateView()
mListHeaderView = (ViewGroup)inflater.inflate(R.layout.listview_header,
listView, false);
onActivityCreated()
listView = this.getListView();
listViewTickets.addHeaderView(mListHeaderView,null,false);

Modified Leoa's answer a bit:
<LinearLayout
android:id="#+id/layoutButtons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0" >
<Button
android:id="#+id/btnLogout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".70"
android:text="left" />
<Button
android:id="#+id/btnMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".30"
android:text="right" />
</LinearLayout>
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/layoutButtons"
android:weightSum=".50" />
Removed the
android:layout_alignParentTop="true"
from the ListView and changed the id of the ListView to #android:id/list.
Also the ListView must be placed below the LinearLayout with the buttons, else you won't be able to use android:layout_below in the ListView.

Related

display button in relativeout below relativelayout

My problem is i cannot show the two button in my layout under the listview. Below i have a listview within a relativelayout. i have a second relativelayout that contains 2 button. the buttons seem to show on top of the list whereas i would like them below the list.
how can i do this?
i've tried setting the 'android:layout_below' in the second RRlayout giving the first layout as the anchor.
Thanks in advance.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="#+id/textviewcarername"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/blue_alpha_background"
android:gravity="center"
android:text="Rota "
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF" />
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/carerdetailsfragrellayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textviewcarername"
android:background="#drawable/textviewbg"
android:padding="10dp" >
<ListView
android:id="#+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cacheColorHint="#0000"
android:divider="#700000ff"
android:dividerHeight="4px" >
</ListView>
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
>
<Button
android:id="#+id/buttonprevious"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Previous" />
<Button
android:id="#+id/buttonnext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Next" />
</RelativeLayout>
</RelativeLayout>
This layout should do the job
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- Header -->
<TextView
android:id="#+id/textviewcarername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/blue_alpha_background"
android:gravity="center"
android:text="Rota "
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF"
/>
<!-- Bottom Layout (Footer) -->
<RelativeLayout
android:id="#+id/rlFooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
>
<Button
android:id="#+id/buttonprevious"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Previous"
/>
<Button
android:id="#+id/buttonnext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Next"
/>
</RelativeLayout>
<!-- ListView -->
<RelativeLayout
android:id="#+id/carerdetailsfragrellayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/textviewcarername"
android:layout_above="#id/rlFooter"
android:background="#drawable/textviewbg"
android:padding="10dp"
>
<ListView
android:id="#+id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cacheColorHint="#0000"
android:divider="#700000ff"
android:dividerHeight="4px"
/>
</RelativeLayout>
</RelativeLayout>
Note that I moved the bottom layout BEFORE the one containing the ListView and assigned it an id, so it could be referred by the ListView container
I also removed the extra namespace definitions
[EDIT]
I now changed the ListView and its container wrap_content to match_parent, in order to fill the remaining space. The ListView should now fit perfectly (I forgot that particular)
[EDIT 2]
You might want to remove the RelativeLayout that encloses the ListView and add its attributes to the ListView itself, to help flattening your design - for performance increase (as little as it may be).
Try this..
<?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" >
<TextView
android:id="#+id/textviewcarername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Rota "
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" />
<RelativeLayout
android:id="#+id/carerdetailsfragrellayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:padding="10dp" >
<ListView
android:id="#+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cacheColorHint="#0000"
android:divider="#700000ff"
android:dividerHeight="4px" >
</ListView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/buttonprevious"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Previous" />
<Button
android:id="#+id/buttonnext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Next" />
</RelativeLayout>
</LinearLayout>
Give an id to the RelativeLayout which contains Buttons as android:id="#+id/button_panel" and add the attribute android:layout_above="#+id/button_panel" in the RelativeLayout which contains ListView as below...
<TextView
android:id="#+id/textviewcarername"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/blue_alpha_background"
android:gravity="center"
android:text="Rota "
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF" />
<RelativeLayout
android:id="#+id/carerdetailsfragrellayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textviewcarername"
android:background="#drawable/textviewbg"
android:layout_above="#+id/button_panel"
android:padding="10dp" >
<ListView
android:id="#+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cacheColorHint="#0000"
android:divider="#700000ff"
android:dividerHeight="4px" >
</ListView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/button_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
android:id="#+id/buttonprevious"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Previous" />
<Button
android:id="#+id/buttonnext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Next" />
</RelativeLayout>

Android - Two buttons in same line filling the whole width

I have a little problem defining a Relative Layout. I have a List View with scroll and two buttons always visible at the bottom of the list view. I just would like my two button have 50% of the width, filling the line. This is my code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="#+id/testbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Save" />
<Button
android:id="#+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/testbutton"
android:text="Cancel"/>
<ListView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/LstPeriodOptions"
android:layout_alignParentTop="true"
android:layout_above="#id/testbutton" />
</RelativeLayout>
I tried to introduce the buttons in a Linear Layout and give the gravity=1 with width=0dp but in that case the ListView dissapears. Could you help me please?
Sorry for my english. This is the result I would like to have:
Thanks a lot, best regards.
EDIT: This is what I tried with Linear Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/container" >
<Button
android:id="#+id/testbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Guardar" />
<Button
android:id="#+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/testbutton"
android:text="Cancelar"/>
</LinearLayout>
<ListView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/LstPeriodOptions"
android:layout_alignParentTop="true"
android:layout_above="#id/container" />
</RelativeLayout>
Did you try with your LinearLayout in this way because this should work. Note all of the property changes. Since I don't know how yours was, I can't point out all of the differences.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/btnLL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:id="#+id/testbutton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save" />
<Button
android:id="#+id/cancelButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel"/>
</LinearLayout>
<ListView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/LstPeriodOptions"
android:layout_above="#id/btnLL" />
</RelativeLayout>
Try out as below to set your button in LinearLayout and set it below your ListView:
<LinearLayout
android:id="#+id/laytbtns"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="#+id/LstPeriodOptions" >
<Button
android:id="#+id/testbutton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:text="Save"/>
<Button
android:id="#+id/cancelButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:text="Cancel" />
</LinearLayout>
Try this..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/LstPeriodOptions"
android:layout_above="#id/testbutton" />
<LinearLayout
android:id="#+id/laytbtns"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="#+id/LstPeriodOptions" >
<Button
android:id="#+id/testbutton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:text="Save"/>
<Button
android:id="#+id/cancelButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:text="Cancel" />
</LinearLayout>
</LinearLayout>

CustomView in ListView

I am creating the listview using custom view(image + frameLayout) , but problem is that when i am clicking on the any item on the list view the getView method is called equal to number of items in the ilst view,
I am giving my xmi file here.
custon_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:id="#+id/imageView1"
android:layout_width="70dp"
android:layout_height="70dp"
android:src="#drawable/ic_launcher"
/>
<FrameLayout
android:id="#+id/frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Landed"
android:layout_gravity="center"
/>
<LinearLayout
android:id="#+id/ll1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<TextView
android:id="#+id/from_user"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="hi"
android:textColor="#000000" />
<TextView
android:id="#+id/from_user_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="hi"
android:textColor="#000000" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
Please Help Me, Thanx in Advance.
hello i was changed your xml file of list please check this.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:id="#+id/imageView1"
android:layout_width="70dp"
android:layout_height="70dp"
android:src="#drawable/icon"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="vertical">
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Landed"
android:layout_gravity="center"
/>
<TextView
android:id="#+id/from_user"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="hi"
android:textColor="#000000" />
<TextView
android:id="#+id/from_user_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="hi"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>
now for list item click clickhere
you can do same click for all list items and you can put different click for different view(mean list items).
its very simple if you have query then comment below.

Making linearlayouts scrollable in android

I am making an android application that needs to use a scrollable layout that contains a couple of linearlayouts, a textview and a listview. How can i make this happen??? Please help and thanks SO much in advance! This is the xml code that i am using so far:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background"
android:orientation="vertical" >
<TextView
android:id="#+id/NotesWelcomeTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/NotesWelcomeText" />
<ListView
android:id="#+android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>
<LinearLayout
android:id="#+id/DeleteAllItemsFromListViewLinearLayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:visibility="invisible" >
<Button
android:id="#+id/CancelButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Cancel" />
<Button
android:id="#+id/DeleteAllButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Delete" />
</LinearLayout>
<LinearLayout
android:id="#+id/DeleteItemFromListViewLinearLayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:visibility="invisible" >
<Button
android:id="#+id/CancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Cancel" />
<Button
android:id="#+id/DeleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Delete" />
</LinearLayout>
<LinearLayout
android:id="#+id/AddItemToListViewLinearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone" >
<EditText
android:id="#+id/AddItemToListViewEditText"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
</EditText>
<Button
android:id="#+id/AddItemToListViewButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/Add" />
</LinearLayout>
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="false"
android:text="#string/terms_and_conditions" />
</ScrollView>
Make your main layout as scroll layout inside that put the linear layout.
Keep in mind Scroll layout can hold only one type of item...
Once you do this, the whole layout is scroll able up and down or left and right as per your XML config.

Making linearlayouts stay at bottom of screen in android

I am making an android application that uses these views:
(Root) - LinearLayout
(Child of root) - ListView + 3 other linearlayouts beneeth that listview. But once i add to many items to the listview, the layouts are being placed outside of the screen. Which i don't want to. How can i make this happen? So that all of the three linearlayouts stay on the screen, at the bottom??? Please help and thanks in advance!
My screen XML code:
<?xml version="1.0" encoding="utf-8"?>
LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background"
android:orientation="vertical" >
<TextView
android:id="#+id/NotesWelcomeTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/NotesWelcomeText" />
<ListView
android:id="#+android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView
<LinearLayout
android:id="#+id/DeleteAllItemsFromListViewLinearLayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:visibility="invisible" >
<Button
android:id="#+id/CancelButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Cancel" />
<Button
android:id="#+id/DeleteAllButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Delete" />
</LinearLayout>
<LinearLayout
android:id="#+id/DeleteItemFromListViewLinearLayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:visibility="invisible" >
<Button
android:id="#+id/CancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Cancel" />
<Button
android:id="#+id/DeleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Delete" />
</LinearLayout>
<LinearLayout
android:id="#+id/AddItemToListViewLinearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone" >
<EditText
android:id="#+id/AddItemToListViewEditText"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
</EditText>
<Button
android:id="#+id/AddItemToListViewButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/Add" />
</LinearLayout>
</LinearLayout>
Try this, you'll have to add the string references and background again, I removed them so I wouldn't have errors
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<TextView android:id="#+id/NotesWelcomeTextView"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="NotesWelcomeText" />
<ListView android:id="#+android:id/list" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_above="#+id/AddItemToListViewLinearLayout"
android:layout_below="#+id/NotesWelcomeTextView">
</ListView>
<LinearLayout android:id="#+id/DeleteAllItemsFromListViewLinearLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1" android:visibility="invisible"
android:layout_alignParentBottom="true">
<Button android:id="#+id/CancelButton2" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Cancel" />
<Button android:id="#+id/DeleteAllButton" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Delete" />
</LinearLayout>
<LinearLayout android:id="#+id/DeleteItemFromListViewLinearLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1" android:visibility="invisible"
android:layout_alignParentBottom="true">
<Button android:id="#+id/CancelButton" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Cancel" />
<Button android:id="#+id/DeleteButton" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Delete" />
</LinearLayout>
<LinearLayout android:id="#+id/AddItemToListViewLinearLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:visibility="gone" android:layout_alignParentBottom="true">
<EditText android:id="#+id/AddItemToListViewEditText"
android:layout_width="250dp" android:layout_height="wrap_content"
android:layout_weight="1">
</EditText>
<Button android:id="#+id/AddItemToListViewButton"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:text="Add" />
</LinearLayout>
Give your ListView a weight of 0 and set its height to 0. This will tell the ListView to only take up the space that is not use by other views.
<ListView ...
android:layout_weight="0"
android:layout_height="0"
...
/>

Categories

Resources