Android: Unable to have two buttons at the bottom of a screen - android

I am trying to have a text view, a list view and two buttons at the bottom of the screen.
Here is my layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="#+id/widget36"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TextView
android:id="#+id/textView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:gravity="center"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true">
</TextView>
<ListView
android:id="#+id/listView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView"
android:layout_alignParentLeft="true"
>
</ListView>
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/darkgray"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
>
<Button
android:id="#+id/doneButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_weight="0.5">
</Button>
<Button
android:id="#+id/cancelButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_right="#+id/doneButton"
android:layout_weight="0.5">
</Button>
</RelativeLayout>
</RelativeLayout>
Can you guys please help me out in figuring out what the issue is>

Most likely you want this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="#+id/widget36"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
>
<TextView
android:id="#+id/textView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:gravity="center_horizontal"
>
</TextView>
<ListView
android:id="#+id/listView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
>
</ListView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/darkgray"
>
<Button
android:id="#+id/doneButton"
android:text="Button"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
>
</Button>
<Button
android:id="#+id/cancelButton"
android:layout_height="wrap_content"
android:text="Button"
android:layout_width="fill_parent"
android:layout_weight="1"
>
</Button>
</LinearLayout>
</LinearLayout>

If you are trying to specifically place items you could try aligning them relative to the other items. So instead of:
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
You could use:
<Button
android:id="#+id/doneButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_weight="0.5">
</Button>
<Button
android:id="#+id/cancelButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/doneButton"
android:layout_weight="0.5">
</Button>

I have made changes in your code, check this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="#+id/widget36"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TextView
android:id="#+id/textView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:gravity="center"
android:layout_above = "#+id/listView"
>
</TextView>
<ListView
android:id="#+id/listView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/relativeLayout"
android:layout_alignParentLeft="true"
>
</ListView>
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#222222"
android:layout_alignParentBottom="true"
android:gravity = "center_horizontal">
<Button
android:id="#+id/doneButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"
android:layout_weight="0.5">
</Button>
<Button
android:id="#+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2"
android:layout_toRightOf="#+id/doneButton"
android:layout_weight="0.5">
</Button>
</RelativeLayout>
</RelativeLayout>

You should set android:layout_width to wrap_content. Setting both buttons to fill_parent means that both buttons are going to be as wide as the screen.

Related

multiple layout in a single xml file

I just want to use multiple layout in a single xml file.I have attached my code below. In that there will be an absolute layout that should be under Horizontal scroll. As a beginner I don't know how to implement it
need your help friends..
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/aagr_background2"
android:orientation="vertical" >
<fragment
android:id="#+id/adview153613"
android:name="com.sentientit.theiWedplanner.Fragadmob"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<RelativeLayout
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#drawable/aanavigationbar" >
<Button
android:id="#+id/back"
android:layout_width="70dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="8dp"
android:layout_marginTop="3dp"
android:layout_x="8px"
android:layout_y="3px"
android:background="#drawable/custom_btn_breaker_bay"
android:text="Back"
android:textColor="#ffffff"
android:textSize="20sp" />
<Button
android:id="#+id/home"
android:layout_width="50px"
android:layout_height="30px"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/back"
android:layout_marginRight="46dp"
android:background="#drawable/home1"
android:paddingBottom="12px"
android:paddingTop="10px"
android:visibility="gone" />
</RelativeLayout>
<AbsoluteLayout
android:layout_width="fill_parent"
android:layout_height="61dp" >
<AbsoluteLayout
android:layout_width="fill_parent"
android:layout_height="61dp"
android:layout_x="120dp"
android:layout_y="35dp" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="38dp"
android:layout_y="30dp"
android:text="- Kid Seated"
android:textColor="#000000"
android:textSize="13dp"
android:typeface="serif" >
</TextView>
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="6dp"
android:layout_y="28dp"
android:src="#drawable/kid" >
</ImageView>
</AbsoluteLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="437dp"
android:layout_y="3dp"
android:src="#drawable/add11_table" />
<Button
android:id="#+id/button3"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="48dp"
android:layout_y="4dp"
android:text="Line"
android:textSize="20sp" />
<Button
android:id="#+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="128dp"
android:layout_y="4dp"
android:text="circle"
android:textSize="20sp" />
<Button
android:id="#+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="212dp"
android:layout_y="6dp"
android:text="vshape"
android:textSize="20sp" />
</AbsoluteLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/table"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
</HorizontalScrollView>
</ScrollView>
Thank you in advance
Not sure whether your looking for this alignment but i just gave a shot..... whenever you wish to fix layout at the bottom of screen make sure you use weight property i.e if you want fix button at the bottom of screen then put android:layout_height = "0dp" and layout_weight="1" for other major layout in the xml and to button which has to be fixed at the bottom use android:layout_height="wrap_content" and layout_weight = "0" that's all is the trick (sorry if i have made it hard to understand... just simply saying play with weight and height property)
<?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="#fff"
android:orientation="vertical" >
<fragment
android:id="#+id/adview153613"
android:name="com.sentientit.theiWedplanner.Fragadmob"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<RelativeLayout
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="#+id/back"
android:layout_width="70dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="8dp"
android:layout_marginTop="3dp"
android:layout_x="8px"
android:layout_y="3px"
android:text="Back"
android:textColor="#ffffff"
android:textSize="20sp" />
<Button
android:id="#+id/home"
android:layout_width="50px"
android:layout_height="30px"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/back"
android:layout_marginRight="46dp"
android:paddingBottom="12px"
android:paddingTop="10px"
android:visibility="gone" />
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/table"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
</HorizontalScrollView>
</ScrollView>
<AbsoluteLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0" >
<AbsoluteLayout
android:layout_width="fill_parent"
android:layout_height="61dp"
android:layout_x="120dp"
android:layout_y="35dp" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="38dp"
android:layout_y="30dp"
android:text="- Kid Seated"
android:textColor="#000000"
android:textSize="13dp"
android:typeface="serif" >
</TextView>
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="6dp"
android:layout_y="28dp" >
</ImageView>
</AbsoluteLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="437dp"
android:layout_y="3dp" />
<Button
android:id="#+id/button3"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="48dp"
android:layout_y="4dp"
android:text="Line"
android:textSize="20sp" />
<Button
android:id="#+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="128dp"
android:layout_y="4dp"
android:text="circle"
android:textSize="20sp" />
<Button
android:id="#+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="212dp"
android:layout_y="6dp"
android:text="vshape"
android:textSize="20sp" />
</AbsoluteLayout>
</LinearLayout>
Yes, you can use use multiple layouts in single XML using the <include>.
Here is a example for that:
<?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:background="#color/app_background"
android:orientation="vertical" >
<include layout="#layout/actionbar_main" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/img_rest_pic"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight=".35"
android:src="#drawable/upload_image" />
</LinearLayout>
</LinearLayout>
The actionbar_main.xml file is in different XML:
<?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="?android:attr/actionBarSize"
android:background="#drawable/navbar_txt"
android:orientation="vertical" >
<ImageButton
android:id="#+id/ibtn_action_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:background="#null"
android:src="#drawable/navbar_back" />
<ImageButton
android:id="#+id/ibtn_action_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/ibtn_action_back"
android:layout_marginRight="5dp"
android:background="#null"
android:src="#drawable/nacbar_setting" />
<View
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:background="#color/white" />
</RelativeLayout>

How to generate Listview with button?

I want to implement a listView with three button below. My xml is given by the code below but the problem is the position of button. In the first time I used only linear but in some time the action of buttons are inversed. So I ought to use Relative layout
<?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"
android:padding="3dp" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="3dp" >
<ListView
android:id="#+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="5dp"
android:layout_weight="1" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/listView"
android:layout_margin="0dp"
android:orientation="horizontal"
android:padding="0dp" >
<Button
android:id="#+id/retour"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="1"
android:padding="0dp"
android:text="#string/cancel" />
<Button
android:id="#+id/Actualise"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="1"
android:gravity="center|center_vertical"
android:padding="0dp"
android:text="Actualiser la liste" />
<Button
android:id="#+id/testbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="1"
android:padding="0dp"
android:text="#string/selection" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
Hope this helps
<?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" >
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="379dp" >
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".33"
android:layout_gravity="center"
android:text="Button" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".33"
android:layout_gravity="center"
android:text="Button" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".33"
android:layout_gravity="center"
android:text="Button" />
</LinearLayout>
</LinearLayout>
Try this code it works fine to show listview qith three button below listview
<?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" >
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/linearLayout1"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</ListView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:id="#+id/linearLayout1"
android:weightSum="3"
>
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>

Android- Proper positioning of layouts

I cant seem to properly position my layouts the way I want them to be.
What my layout looks like is like this:
LinearLayout
LinearLayout
ListView
LinearLayout
TextView
TextView
TextView
Button
My aim is to have it like this:
Any thoughts on this please as to what Layouts i will use?
Help will be appreciated
try this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/homeTableLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
>
<LinearLayout
android:layout_centerInParent="true"
android:layout_width="fill_parent"
android:layout_height="100dip"
android:background="#android:color/holo_blue_dark"
>
<!-- arrange your lables and button here -->
</LinearLayout>
<LinearLayout
android:layout_width="100dip"
android:layout_height="fill_parent"
android:background="#android:color/holo_purple"
android:layout_marginLeft="20dip"
>
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
></ListView>
</LinearLayout>
</RelativeLayout>
look the wireframe below . you can set corner-radius and add controls in it.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/layout2"
android:layout_width="fill_parent"
android:layout_height="200dip"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" >
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="100dip"
android:layout_weight="1" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="#+id/layout1"
android:layout_width="100dip"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
</LinearLayout>
</RelativeLayout>
You can use the Relative layout for this as follows
<?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" >
<RelativeLayout
android:id="#+id/first_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dip" >
<Button
android:id="#+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn1" />
<Button
android:id="#+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn2" />
<Button
android:id="#+id/btn4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn3" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/second_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_toRightOf="#+id/first_layout" >
<GridView
android:id="#+id/gridview"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</GridView>
<Button
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
</RelativeLayout>

android RelativeLayout

is it possible to use RelativeLayout to have one area on top, which uses all available space (wich should be filled some Views dynamically) and to Buttons which should be on the lower end of the screen?
I tried following, but with no effort:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<FrameLayout
android:id="#+id/topFrame"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_margin="6dp">
<TextView
android:text="blabla"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
<Button android:id="#+id/button1"
android:text="Button 1"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#id/topFrame"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_margin="6dp" />
<Button android:id="#+id/button2"
android:text="Button 2"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#id/button1"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_margin="6dp" />
whith this solution the button fills the space and not the FrameLayout.
TRy this:
<RelativeLayout......>
<FrameLayout
android:id="#+id/topFrame"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_margin="6dp">
<TextView
android:text="blabla"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
<RelativeLayout
android:id="#+id/InnerRelativeLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
.....
</Button>
<Button
.....
</Button>
</RelativeLayout>
</RelativeLayout>
In the FrameLayout, change android:layout_height="wrap_content" to android:layout_height="fill_parent" then include android:layout_above="#+id/button1". It should force the force the FrameLayout to fill the space and always be above the first button.
Try this.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="#+id/RelativeLayout1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button1"
android:text="Button"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"/>
<Button android:layout_height="wrap_content"
android:id="#+id/button2"
android:text="Button"
android:layout_above="#+id/button1"
android:layout_width="fill_parent"
android:layout_alignParentLeft="true"/>
<FrameLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/frameLayout1"
android:layout_above="#+id/button2"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true">
<TextView android:layout_height="wrap_content"
android:text="TextView"
android:layout_width="fill_parent"
android:id="#+id/textView1">
</TextView>
</FrameLayout>
</RelativeLayout>
Sorry if I missed something.

Android layout XML code

Can somebody plz post the xml layout code for this (have a look at the link), really don't get this done...
Thanks.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="#+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:background="#drawable/background" android:layout_gravity="bottom" android:orientation="vertical" android:baselineAligned="false">
<ImageView android:id="#+id/ImageView01" android:layout_width="fill_parent" android:background="#drawable/logo" android:layout_height="wrap_content"></ImageView>
<LinearLayout android:layout_gravity="center_vertical" android:id="#+id/LinearLayout02" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"><Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="#+id/Button02" android:layout_gravity="right" android:text="#+id/Button02"></Button>
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="#+id/Button03" android:text="#+id/Button03"></Button>
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="#+id/Button01" android:layout_gravity="bottom" android:text="#+id/Button01"></Button>
</LinearLayout>
</LinearLayout>
Try to use RelativeLayout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="#+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<RelativeLayout
android:id="#+id/LinearLayout02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
>
<Button
android:id="#+id/Button02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#+id/Button02"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
>
</Button>
<Button
android:id="#+id/Button03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#+id/Button03"
android:layout_toLeftOf="#+id/Button02"
android:layout_alignParentBottom="true"
>
</Button>
<Button
android:id="#+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#+id/Button01"
android:layout_above="#+id/Button02"
android:layout_alignParentRight="true"
>
</Button>
</RelativeLayout>
<ImageView
android:id="#+id/ImageView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
>
</ImageView>

Categories

Resources