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?
Related
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.
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 new android development. Below i attach my layout file.
In my layout i have one ListView and one EditText with ImageButton. When i insert task in EditText and press the ImageButton that task will be added in ListView one by one.
My problem is suppose i add more than 4 task means the EditText with ImageButton view is not visible because the list items take that place please give solution thanks...
Layout:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ListView
android:id="#+id/frontpagetasklistid"
android:layout_width="fill_parent"
android:layout_height="375dp" >
</ListView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
>
<EditText
android:id="#+id/edittextidAddTodayTask"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/edittextselector"
android:hint="Add Today Task"/>
<ImageButton
android:id="#+id/imagebuttonidAddTodayTask"
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="#drawable/addtask" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
try this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/button_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
>
<EditText
android:id="#+id/edittextidAddTodayTask"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/edittextselector"
android:hint="Add Today Task"/>
<ImageButton
android:id="#+id/imagebuttonidAddTodayTask"
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="#drawable/addtask" />
</RelativeLayout>
<ListView
android:id="#+id/frontpagetasklistid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/button_layout">
</ListView>
</RelativeLayout>
or
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="#+id/frontpagetasklistid"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_above="#+id/button_layout">
</ListView>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
>
<EditText
android:id="#+id/edittextidAddTodayTask"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/edittextselector"
android:hint="Add Today Task"/>
<ImageButton
android:id="#+id/imagebuttonidAddTodayTask"
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="#drawable/addtask" />
</RelativeLayout>
</LinearLayout>
i am guessing that your edittext and imagebutton are below your listview.. In that case you can add this views in listview's footer.. you can google to find how to add views in listview footer
here is a good example:
Align Button and EditText on Relative Layout
Hope it helps you!!
I have not run the below solution , But you can achieve it by using layout_weightSum and layout_weight property.
<?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"
android:layout_weigthSum="1">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.9">
<ListView
android:id="#+id/frontpagetasklistid"
android:layout_width="fill_parent"
android:layout_height="375dp" >
</ListView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.1">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
>
<EditText
android:id="#+id/edittextidAddTodayTask"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/edittextselector"
android:hint="Add Today Task"/>
<ImageButton
android:id="#+id/imagebuttonidAddTodayTask"
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="#drawable/addtask" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
I would need to try it, to proof me right, but it should work to put the ListView into a ScrollView with fixed height.
Edited:
Try to add your editText and ImageButton like footer:
<?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" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="#+id/lay1">
<ListView
android:id="#+id/frontpagetasklistid"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ListView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/lay1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
>
<ImageButton
android:id="#+id/imagebuttonidAddTodayTask"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="#drawable/addtask"
/>
<EditText
android:id="#+id/edittextidAddTodayTask"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:ems="10"
android:background="#drawable/edittextselector"
android:hint="Add Today Task" />
</RelativeLayout>
This will might help you....
I've a relative layout in android for a chat application.The problem is that the listview on my screen when grows the last elements are hidden behind the textbox and button which I've placed at the bottom.
I am using the following layout file.
<?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:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView android:id="#+id/PreviousChatsButton"
android:padding="5dip"
android:text="#string/ViewPreviousChats"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:focusable="true"
>
</TextView>
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<TextView android:id="#+id/NoChatsMsg"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/NoNewChatMsg"
/>
<Button
android:id="#+id/SubmitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="#string/Submit"
android:onClick="SubmitButtonClick" />
<EditText
android:id="#+id/Chatbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/SubmitButton"
android:layout_alignBottom="#id/SubmitButton"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/SubmitButton"
android:ems="10"
android:inputType="text" >
</EditText>
</RelativeLayout>
what you want to do is in the LinearLayout do android:layout_above="#+id/Chatbox" that will make sure it does not go below it
//try this its working fine for me
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/PreviousChatsButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:gravity="center_horizontal"
android:padding="5dip"
android:text="ViewPreviousChats" >
</TextView>
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/NoChatsMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/NoNewChatMsg" />
<Button
android:id="#+id/SubmitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:onClick="SubmitButtonClick"
android:text="#string/Submit" />
<EditText
android:id="#+id/Chatbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/SubmitButton"
android:layout_alignBottom="#id/SubmitButton"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/SubmitButton"
android:ems="10"
android:inputType="text" >
</EditText>
</LinearLayout>
</LinearLayout>
Use android:layout_above to avoid this problem :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="#+id/SubmitButton" ... />
<LinearLayout
android:layout_above="#id/SubmitButton" ... >
...
</LinearLayout>
Note that you have to declare your button before the LinearLayout for this to work.
I have a list view, editText and button. editText and button are my footer to the listview. What is want is the footer to be positioned at the bottom of the screen and the listview to be scrollable above the footer. My layout is something like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:>
</ListView>
<EditText
android:id="#+id/txtType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/add" />
<Button
android:id="#+id/add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:onClick="onClick"
android:text="Add" />
</RelativeLayout>
I have achieved above picture but my problem is that the listview scrolls below my footer. Footer is like floating over the listview. I want the listview to be scrollable above this footer only. help me
<?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">
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="#+id/bbar">
</ListView>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:id="#+id/bbar">
<EditText
android:id="#+id/txtType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/add" />
<Button
android:id="#+id/add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:onClick="onClick"
android:text="Add" />
</RelativeLayout>
</RelativeLayout>
Give Editbox and button in another LinearLayout,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:>
</ListView>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center" >
<EditText
android:id="#+id/txtType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/add" />
<Button
android:id="#+id/add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:onClick="onClick"
android:text="Add" />
</LinearLayout>
</RelativeLayout>
Thanks....
Wrap Editbox and button in another LinearLayout, . then use alignParentBottom=true property for the Linear Layout .
Just add this android:layout_above="#+id/txtType" to your ListView.
<?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/txtType"
android:layout_alignParentTop="true"
android:="" >
</ListView>
<EditText
android:id="#+id/txtType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/add" />
<Button
android:id="#+id/add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:onClick="onClick"
android:text="Add" />
</RelativeLayout>
check out this this is working for me
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:background="#drawable/login_page_bg"
android:layout_height="fill_parent"
>
<ListView
android:id="#android:id/list"
android:layout_above="#+id/footerlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<RelativeLayout
android:id="#+id/footerlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:onClick="onClickAddChild"
android:text="Add+"/>
</RelativeLayout>
</RelativeLayout>