Hello,
I've been trying to create a RelativeLayout with a header, body (list) and footer. I want the header to be above everything (aligned to top), the body (list) to be under the header (when scrolling) and the footer (aligned to bottom) to be above the body (list) - only when it's visible.
I've managed to do so PERFECTLY when it comes to how things look but apparently the XML layout is the cause to the issues I've been having when clicking on listItems (see here, and here).
In order to solve the issues, I had to wrap the ListView with LinearLayout and put it between the header and the footer (in the XML). This solves the listItems clicking issues BUT creates a new issue - the footer hides the last ListView item, even though the list does go under the header when scrolling it down.
I'm pretty much desperate here :\
This is the XML which creates the perfect layout but causes the List Item clicking issues:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#ffffff"
>
<RelativeLayout
android:background="@drawable/top_background"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:id="@+id/top_control_bar"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Droidmarks"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/add_bookmark"
android:textSize="20dip"
android:textColor="#a0cb26"
android:shadowColor="#7a9b1b"
android:shadowRadius="5"
android:layout_marginLeft="5dip"
android:gravity="left|center" />
<Button
android:id="@+id/add_bookmark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center"
android:layout_alignParentRight="true"
android:text="Add"
/>
</RelativeLayout>
<LinearLayout
android:id="@+id/bottom_control_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/top_background"
android:visibility="invisible"
>
<Button
android:id="@+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center"
android:layout_alignParentRight="true"
android:text="Add"
/>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/top_control_bar"
android:layout_above="@id/bottom_control_bar"
android:drawSelectorOnTop="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:cacheColorHint="#ffffff"
android:listSelector="@drawable/selected_item"
/>
<TextView android:id="@android:id/empty" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Bookmarks found. You can add one by clicking the star."
android:layout_below="@id/top_control_bar" android:layout_above="@id/bottom_control_bar" />
</RelativeLayout>
This is the XML which hide the last List Item but solves the clicking issues:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#ffffff"
>
<RelativeLayout
android:background="@drawable/top_background"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:id="@+id/top_control_bar"
android:layout_alignParentTop="true"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Droidmarks"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/add_bookmark"
android:textSize="20dip"
android:textColor="#a0cb26"
android:shadowColor="#7a9b1b"
android:shadowRadius="5"
android:layout_marginLeft="5dip"
android:gravity="left|center" />
<Button
android:id="@+id/add_bookmark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center"
android:layout_alignParentRight="true"
android:text="Add"
/>
</RelativeLayout>
<LinearLayout
android:id="@+id/listArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@id/top_control_bar"
>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false"
android:cacheColorHint="#ffffff" />
<TextView android:id="@android:id/empty" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Bookmarks found. You can add one by clicking the star." />
</LinearLayout>
<LinearLayout
android:id="@+id/bottom_control_bar"
android:layout_above="@id/listArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/top_background"
android:orientation="horizontal"
android:visibility="visible"
>
<Button
android:id="@+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center"
android:layout_alignParentRight="true"
android:text="Add"
/>
</LinearLayout>
</RelativeLayout>
I'd appreciate any help to somehow find a solution for both issues!
Thank you!