I have made an Android activity. In this activity I have a ListView and a Button. I want to add the Button to the bottom of screen. I have tried so long but it's hidden from tabbar. My xml code is as below. Please help me.
code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.eps.blancatours.uc.Header
android:id="#+id/hdr_dest_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<RelativeLayout
android:id="#+id/rl_main_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/hdr_dest_list"
android:padding="10dp" >
<ListView
android:id="#+id/dest_List"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/btn_next" />
<Button
android:id="#+id/btn_next"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="40dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="#D41016"
android:text="#string/next"
android:textColor="#ffffff"
android:textSize="14dp" />
</RelativeLayout>
</RelativeLayout>
Make changes like below -
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<LinearLayout android:id="#+id/li"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<com.eps.blancatours.uc.Header
android:id="#+id/hdr_dest_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/button1"
android:id="#+id/list"
android:padding="30dp"
/>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#68bdb6"
android:text="#string/Select" />
</RelativeLayout>
You did not close your main Relativelayout just close that layout button will appear below the listview
You didn't close your main RelativeLayout with </RelativeLayout>.
For me your code works, you just have to close your relative layout.
It does working here, all I added is just </RelativeLayout> tag before the parent tag.
and my text in place of the #String reference.
also Try changing android version when rendering layout.
Wrapping ListView and Button with nested RelativeLayout is redundant. You could set you XML like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.eps.blancatours.uc.Header
android:id="#+id/hdr_dest_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<ListView
android:id="#+id/dest_List"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/hdr_dest_list"
android:layout_above="#+id/btn_next" />
<Button
android:id="#+id/btn_next"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="40dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:background="#D41016"
android:text="#string/next"
android:textColor="#ffffff"
android:textSize="14dp" />
</RelativeLayout>
Also use match_parent instead fill_parent
Add the below inside Button
android:layout_below="#id/list"
Add android:orientation="vertical" on your both RelativeLayouts as
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.eps.blancatours.uc.Header
android:id="#+id/hdr_dest_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<RelativeLayout
android:id="#+id/rl_main_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/hdr_dest_list"
android:padding="10dp"
android:orientation="vertical" >
<ListView
android:id="#+id/dest_List"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/btn_next" />
<Button
android:id="#+id/btn_next"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="40dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="#D41016"
android:text="#string/next"
android:textColor="#ffffff"
android:textSize="14dp" />
</RelativeLayout>
</RelativeLayout>
And don't forget to clear the project.
Related
i'm new in android.
i have looking for how to make a button create new message like in bbm/whatsapp, i have set the layout.
<ScrollView
android:id="#+id/sv_req_out_list"
android:layout_width="match_parent"
android:layout_height="500dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:background="#color/white"
android:fillViewport="true" >
<ImageView
android:id="#+id/imgNewReq"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:paddingRight="20dp"
android:layout_marginBottom="100dp"
android:scaleType="fitXY"
android:src="#drawable/ico_circle_additem" />
</ScrollView>
and i want when scroll up and down, the position not changed.
Please help, thanks
put the button outside scrollView
<?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"
>
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
<ScrollView
android:id="#+id/sv_req_out_list"
android:layout_width="match_parent"
android:layout_height="500dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:background="#ffffff"
android:fillViewport="true" >
<ImageView
android:id="#+id/imgNewReq"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:paddingRight="20dp"
android:layout_marginBottom="100dp"
android:scaleType="fitXY"
android:src="#drawable/ico_circle_additem" />
</ScrollView>
</LinearLayout>
I have a ListView in an activity. In this ListView I am calling another xml file to set text properties and add an arrow image. With only TextView, I am able to set top and bottom margin of the ListView row but when I add arrow image, the bottom margin doesn't set but top margin works properly. Please let me know, where I am doing wrong. Here's my code of xml file below :
list_text_black.xml file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:adjustViewBounds="true"
android:maxWidth="30dp"
android:maxHeight="30dp"
android:src="#drawable/arrow1" />
<TextView
android:id="#+id/list_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView1"
android:layout_alignParentLeft="true"
android:layout_marginLeft="16dp"
android:text="sdfjijogbvfbghgggg"
android:textColor="#000000"
android:textSize="18dp"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
listview_file.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="fill_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/listView1"
android:layout_width="fill_parent"
android:layout_height="270dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:choiceMode="singleChoice"
android:layout_weight="1.32" >
</ListView>
</LinearLayout>
try this this may help you,
<?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="#android:color/black"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" >
<TextView
android:id="#+id/list_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="16dp"
android:text="Just Test"
android:textColor="#android:color/white"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:adjustViewBounds="true"
android:maxHeight="30dp"
android:maxWidth="30dp"
android:src="#drawable/arrow" />
</RelativeLayout>
</LinearLayout>
if i am getting what you want then this may help. use android:paddingBottom = "12dp" in <ImageView>..<ImageView/>
I've tried everything, and looked up everywhere..!
I'm trying to put a listview within a scrollview, and a button at the bottom of the screen fixed..
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" >
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/rlCommento" />
<RelativeLayout
android:id="#+id/rlCommento"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" >
<EditText
android:id="#+id/etCCommento"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_weight="15"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="#+id/bCInviaCommento"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/etCCommento"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_weight="85"
android:text="Commenta!" />
</RelativeLayout>
</RelativeLayout>
It seems working in the project, but when I try it on the emulator, it doesn't work!
Any advice ? Thanks!
This is what you have to do:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:text="Button" />
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/button1"
android:layout_centerHorizontal="true" >
</ListView>
</RelativeLayout>
You can use LinearLayout.
<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:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<RelativeLayout
android:id="#+id/rlCommento"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
...
</RelativeLayout>
</LinearLayout>
First: Don't put list view inside scroll view
Second: make your top most parent width n height to match parent
Third: add a new layout at bottom and add button inside this layout, something like this, give layout some weight
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_weight="1"
android:orientation="horizontal"
android:paddingBottom="7dp"
android:paddingTop="7dp" >
<Button
android:id="#+id/score_board"
android:layout_width="wrap_content"
android:layout_height="55dp"
android:layout_gravity="center"
android:layout_weight="1"
android:text="OK" />
</LinearLayout>
// Try this way,hope this will help you to solve your problem...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp">
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"/>
<LinearLayout
android:id="#+id/rlCommento"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<EditText
android:id="#+id/etCCommento"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="#+id/bCInviaCommento"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="Commenta!" />
</LinearLayout>
</LinearLayout>
To do that you have to LinearLayout vertical instead of RelativeLayout and set ListView weight=1 and layout_height=0dp.
This should work just as needed:
<?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:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<RelativeLayout
android:id="#+id/rlCommento"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/etCCommento"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_weight="15"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="#+id/bCInviaCommento"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/etCCommento"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_weight="85"
android:text="Commenta!" />
</RelativeLayout>
Hope I understood your problem correctly. No need of keeping ListView inside scrollview. Just try following snippet. It will may for you.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:id="#+id/bCInviaCommento"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Commenta!"
android:layout_below="#id/list" />
</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>
I am really getting frustrated with the layout as shown below:
I would like to have listview and below that I need to have two buttons side by side as shown above(LIstview should be scrollable and buttons should be as bottom bar ie..ontop tof the listview ). I have tried using android:layout_above and android:layout_below but nothing worked.Can anyone gimme an idea how to achieve this layout ?
This is what my layout code as of now actually I have this code where I am able to achieve this but I'm unable to click the buttons here.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/secondLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp" >
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="#+id/firstLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/secondLayout"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#00ffffff"
android:gravity="bottom"
android:orientation="horizontal"
android:padding="15dp" >
<Button
android:id="#+id/btnPrevious"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="#drawable/redbutton"
android:onClick=""
android:text="Previous"
android:textColor="#ffffff" />
<Button
android:id="#+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="#drawable/redbutton"
android:text="Next"
android:textColor="#ffffff" />
</LinearLayout>
Step #1: Get rid of the useless LinearLayout wrapping your ListView, moving the android:padding attribute into the ListView.
Step #2: Add android:layout_alignParentTop="true" and android:layout_above="#+id/firstLayout to the ListView.
Step #3: Get rid of android:layout_above="#id/secondLayout" from the remaining LinearLayout, as you definitely do not want that above the ListView.
Step #4: Switch from dp to sp for your Button dimensions, to take into account font scaling.
Step #5: Either change the width of the LinearLayout to wrap_content or remove the android:layout_centerHorizontal="true", as you cannot center something that fills all available space.
Off the cuff, the rest should be OK, or at least be a lot closer to what you want.
how about adding the buttons to your actionbar?
Otherwise wrap the ListView inside an ScrollView and make your RelativeLayout to LinearLayout
this is working. What problem are you facing exactly?
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/secondLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp" >
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="#+id/firstLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/secondLayout"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#00ffff"
android:gravity="bottom"
android:orientation="horizontal"
android:padding="15dp" >
<Button
android:id="#+id/btnPrevious"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="#FF0000"
android:onClick="test"
android:text="Previous"
android:textColor="#ffffff" />
<Button
android:id="#+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:onClick="test"
android:background="#FF0000"
android:text="Next"
android:textColor="#ffffff" />
</LinearLayout>
This may work for you:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="#+id/firstLayout" />
<LinearLayout
android:id="#+id/firstLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#00ffffff"
android:orientation="horizontal"
android:padding="15dp" >
<Button
android:id="#+id/btnPrevious"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:onClick=""
android:text="Previous"
android:textColor="#ffffff" />
<Button
android:id="#+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="Next"
android:textColor="#ffffff" />
</LinearLayout>
</RelativeLayout>