in my app i have a application bar at the top and an tab bar at the bottom. These two are been fixed. Inbetween of them i have place a ViewFipper. Inside the view flipper i have 7 text views, one image views and an 3 image buttons.
Now my problem is i want to show all these inside the space between the application bar and the tab bar in all devices. When i check the layout with 2.7 in QVGA the last buttons get hided behind the tab bar. Whereas in 3.2 in HVGA(ADP2) there are more spaces between the last two image buttons and the tab bar. I want the contents inside the view flipper to be exactly in the middle space, there should not be any scroll view in my layout. How to get this….
Following id my layout design
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/relativeLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/back" xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:layout_width="fill_parent" android:layout_marginBottom="10dp"
android:background="@drawable/graybar" android:layout_height="wrap_content"
android:id="@+id/relativeLayout2">
<TextView android:text="Detail" android:id="@+id/textView1"
android:textSize="24sp" android:layout_centerInParent="true"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
<TextView android:layout_width="wrap_content" android:text="Share Festival"
android:gravity="center" android:textStyle="bold"
android:layout_height="wrap_content" android:id="@+id/DetailShare"
android:layout_alignParentRight="true" android:background="@drawable/share">
</TextView>
</RelativeLayout>
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_below="@+id/relativeLayout2" android:layout_above="@+id/relativeLayout4"
android:id="@+id/flipper" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout android:id="@+id/RLL"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical" android:layout_marginBottom="10dp"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="@+id/LL" android:gravity="center">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="@+id/imageView1"
android:src="@drawable/p144" android:layout_alignParentTop="true">
</ImageView>
</LinearLayout>
<RelativeLayout android:layout_width="fill_parent"
android:layout_below="@+id/LL" android:layout_height="wrap_content"
android:id="@+id/RL1">
<ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/detailback"
android:layout_alignParentLeft="true" android:background="@drawable/left">
</ImageButton>
<TextView android:text="Detail" android:id="@+id/textView1"
android:background="@drawable/share" android:textSize="15sp"
android:layout_centerInParent="true" android:gravity="center"
android:maxLines="2" android:layout_height="wrap_content"
android:layout_width="wrap_content">
</TextView>
<ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/DetailShare"
android:layout_alignParentRight="true" android:background="@drawable/right">
</ImageButton>
</RelativeLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="@+id/Lq1" android:layout_below="@+id/RL1">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="@+id/L2">
<TextView android:text="date" android:id="@+id/date"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="@+id/L2">
<TextView android:text="Contact : " android:id="@+id/contact"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="@+id/L2">
<TextView android:text="mail" android:id="@+id/mail"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="@+id/L2">
<TextView android:text="phone" android:id="@+id/phone"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="@+id/L2">
<TextView android:text="Hollywood" android:id="@+id/address"
android:textSize="18sp" android:layout_marginTop="5dp" android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="@+id/L2">
<TextView android:text="DeadLine : closed 2011 festival"
android:id="@+id/date" android:textSize="18sp"
android:layout_marginTop="5dp" android:layout_gravity="center" android:layout_height="wrap_content"
android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="@+id/L2">
<TextView android:text="Genre" android:id="@+id/genre"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
</LinearLayout>
<RelativeLayout android:id="@+id/Relativelayoutadd" android:layout_height="wrap_content" android:layout_width="fill_parent"
android:layout_below="@+id/Lq1" android:layout_alignBaseline="@+id/flipper">
<TextView android:text="Add to IPhone calendar" android:id="@+id/calendar"
android:textSize="15sp" android:layout_marginBottom="5dp"
android:layout_alignParentLeft="true"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
<TextView android:text="Add to favorite" android:id="@+id/addtofavorite"
android:textSize="15sp" android:layout_marginBottom="5dp"
android:layout_alignParentRight="true"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</RelativeLayout>
</RelativeLayout>
</ViewFlipper>
<RelativeLayout android:layout_width="fill_parent"
android:layout_gravity="bottom" android:layout_alignParentBottom="true"
android:background="@drawable/applicarion_bar" android:layout_height="wrap_content"
android:id="@+id/relativeLayout4">
<ImageButton android:layout_width="wrap_content"
android:layout_marginLeft="5dp" android:layout_height="wrap_content"
android:id="@+id/detailfestivallist" android:layout_alignParentLeft="true"
android:background="@drawable/festival_btn">
</ImageButton>
<ImageButton android:layout_width="wrap_content"
android:layout_marginLeft="90dp" android:layout_height="wrap_content"
android:id="@+id/detailsearch" android:layout_alignParentLeft="true"
android:background="@drawable/search_btn">
</ImageButton>
<TextView android:layout_width="wrap_content" android:text="MAR 20"
android:textSize="9sp" android:layout_marginLeft="170dp"
android:layout_height="wrap_content" android:id="@+id/detailcalendar"
android:layout_alignParentLeft="true" android:background="@drawable/calendar_btn">
</TextView>
<ImageButton android:layout_width="wrap_content"
android:layout_marginRight="5dp" android:layout_height="wrap_content"
android:id="@+id/detailfavorite" android:layout_alignParentRight="true"
android:background="@drawable/favorite_btn">
</ImageButton>
</RelativeLayout>
</RelativeLayout>
First, you have two different elements called android:id=”@+id/date”. This might give conflicts, and awkward behavior.
Secondly, the android:id=”@+id/RLL” is only used to position items vertically. Therefore consider using a LinearLayout instead.
In general, I think your layout uses too much containers. I’ve created another layout (and replaced the drawables with colours, since i don’t have the drawables) which you might use for inspiration to create a simpler, and flexible layout. As commented by Siva K, you can use the android:layout_weight=”1″ for the elements in the center (in the LinearLayout) to space them evenly…
Below is an example (only the viewFlipper part, the rest is unchanged)
Hope this works for you.