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>
Related
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>
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>
Here is my layout:
Here is my XML. My layout is good except the red color part. I could not able to bring it into view. There is issue in the alignment. Is there a tool to design the layouts easily? Always facing issue in the alignments compatible to all resolutions and for both portrait and landscape dimensions.
<?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" >
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/linearLayout3"
android:background="#fff"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="#fff"
android:orientation="vertical" >
<ImageView
android:id="#+id/productImageView"
android:layout_width="fill_parent"
android:layout_height="380dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="420dp"
android:background="#fff"
android:orientation="horizontal" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip" >
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/linearLayout3"
android:background="#fff"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="5dip"
android:layout_toLeftOf="#+id/linearLayout3"
android:background="#fff"
android:orientation="vertical" >
<TextView
android:id="#+id/product_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="5dip"
android:layout_toLeftOf="#+id/linearLayout3"
android:background="#fff"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/linearLayout7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/linearLayout3"
android:layout_weight="1"
android:background="#fff"
android:orientation="horizontal" >
<TextView
android:id="#+id/your_price_tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Your Price" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/linearLayout3"
android:layout_weight="1"
android:background="#fff"
android:orientation="horizontal" >
<TextView
android:id="#+id/your_price"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="5dip"
android:layout_toLeftOf="#+id/linearLayout3"
android:background="#fff"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/linearLayout9"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/linearLayout3"
android:layout_weight="1"
android:background="#fff"
android:orientation="horizontal" >
<TextView
android:id="#+id/button4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Retail Price" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/linearLayout3"
android:layout_weight="1"
android:background="#fff"
android:orientation="horizontal" >
<TextView
android:id="#+id/retail_price"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="70dip"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/linearLayout2"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/linearLayout2"
android:background="#c0c0c0"
android:orientation="vertical" >
<ImageView
android:id="#+id/button6"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/linearLayout15"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="5dip"
android:background="#c0c0c0"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayout11"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="5dip"
android:background="#c0c0c0"
android:orientation="horizontal" >
<Button
android:id="#+id/button6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Buy Now" />
<Button
android:id="#+id/button7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Gush It" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout12"
android:layout_width="fill_parent"
android:layout_height="30dip"
android:layout_alignParentRight="true"
android:layout_marginTop="5dip"
android:background="#c0c0c0"
android:orientation="vertical" >
<TextView
android:id="#+id/button6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Description" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout13"
android:layout_width="fill_parent"
android:layout_height="60dip"
android:layout_alignParentRight="true"
android:layout_marginTop="5dip"
android:background="#c0c0c0"
android:orientation="vertical" >
<TextView
android:id="#+id/product_description"
android:layout_width="fill_parent"
android:layout_height="400dp"
android:text="Button" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
If you are making a grid like this, I would prefer a GridLayout
You can set view's to specific position [+ width/height] in the GridLayout using the Spec objects in the LayoutParam
I am trying to achieve this user interface
through the layout. But getting issues in the alignments. Along with this, which is the best way either to use LinearLayout or RelativeLayout in general? Getting many references suggesting both.
here is my xml:
<?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" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="400dp"
android:src="#drawable/splash_landscape" />
<TextView
android:layout_width="301dp"
android:layout_height="100dp"
android:text="Product Name" />
<TextView
android:id="#+id/textView1"
android:layout_width="323dp"
android:layout_height="82dp"
android:text="TextView" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:layout_width="300dp"
android:layout_height="100dp"
android:text="Product Name"
></TextView>
<RelativeLayout >
<TextView android:layout_width="200dp"
android:layout_height="100dp"
android:text="Product Name"
></TextView>
</RelativeLayout>
<RelativeLayout >
<TextView android:layout_width="200dp"
android:layout_height="100dp"
android:text="Product Name"
></TextView>
<TextView android:layout_width="200dp"
android:layout_height="100dp"
android:text="Product Name"
></TextView>
</RelativeLayout>
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/launcher" />
</LinearLayout>
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
I have tried the above layout and I reached to near that. Below is the xml file and screen shot
<?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" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="60dip"
android:orientation="vertical" android:background="#c0c0c0">
<Button
android:id="#+id/button8"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Button" />
</LinearLayout>
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_marginTop="5dip">
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" android:layout_toLeftOf="#+id/linearLayout3" android:layout_alignParentLeft="true" android:background="#fff">
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" android:layout_toLeftOf="#+id/linearLayout3" android:layout_alignParentLeft="true" android:background="#fff" android:layout_marginTop="5dip">
<Button
android:id="#+id/button3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_toLeftOf="#+id/linearLayout3" android:layout_alignParentLeft="true" android:background="#fff" android:layout_marginTop="5dip">
<LinearLayout
android:id="#+id/linearLayout7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_toLeftOf="#+id/linearLayout3" android:layout_alignParentLeft="true" android:background="#fff" android:layout_weight="1">
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_toLeftOf="#+id/linearLayout3" android:layout_alignParentLeft="true" android:background="#fff" android:layout_weight="1">
<Button
android:id="#+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_toLeftOf="#+id/linearLayout3" android:layout_alignParentLeft="true" android:background="#fff" android:layout_marginTop="5dip">
<LinearLayout
android:id="#+id/linearLayout9"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_toLeftOf="#+id/linearLayout3" android:layout_alignParentLeft="true" android:background="#fff" android:layout_weight="1">
<Button
android:id="#+id/button4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_toLeftOf="#+id/linearLayout3" android:layout_alignParentLeft="true" android:background="#fff" android:layout_weight="1">
<Button
android:id="#+id/button5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="70dip"
android:layout_height="wrap_content"
android:orientation="vertical" android:layout_alignParentRight="true" android:background="#c0c0c0" android:layout_alignBottom="#+id/linearLayout2" android:layout_alignTop="#+id/linearLayout2">
<Button
android:id="#+id/button6"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/linearLayout11"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#c0c0c0"
android:orientation="horizontal" android:layout_marginTop="5dip">
<Button
android:id="#+id/button6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button" android:layout_weight="1"/>
<Button
android:id="#+id/button7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button" android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout12"
android:layout_width="fill_parent"
android:layout_height="30dip"
android:orientation="vertical" android:layout_alignParentRight="true" android:background="#c0c0c0" android:layout_marginTop="5dip">
<Button
android:id="#+id/button6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout13"
android:layout_width="fill_parent"
android:layout_height="60dip"
android:orientation="vertical" android:layout_alignParentRight="true" android:background="#c0c0c0" android:layout_marginTop="5dip">
<Button
android:id="#+id/button6"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Button" />
</LinearLayout>
</LinearLayout>
I would definitely use RelativeLayout as your root. Then it would be much easier to arrange all views by using below,toRightOf,alignParentLeft and so on..
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.