Centering a table layout in scroll view - android

Currently, I have a scrollview set up like so for when the keyboard pops up:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
android:background="#drawable/home_background"
>
<RelativeLayout
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fillViewport="true"
android:gravity="center" >
<LinearLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:weightSum="2"
>
<!-- 2 columns -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:orientation="horizontal"
android:layout_weight="2">
<TextView
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Heading1"
/>
<TextView
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Heading2"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:layout_weight="2">
<TextView
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Label1: "
/>
<EditText
android:layout_weight="1"
android:id="#+id/editLabel1"
android:textColor="#C0C0C0"
android:layout_width="75dp"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:layout_weight="2">
<TextView
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Label2: "
/>
<EditText
android:id="#+id/editLabel2"
android:layout_weight="1"
android:textColor="#C0C0C0"
android:layout_width="75dp"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:layout_weight="2">
<TextView
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Label3: "
/>
<EditText
android:layout_weight="1"
android:id="#+id/editLabel3"
android:textColor="#C0C0C0"
android:layout_width="75dp"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:layout_weight="2">
<TextView
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Label4: "
/>
<EditText
android:layout_weight="1"
android:id="#+id/editLabel4"
android:textColor="#C0C0C0"
android:layout_width="75dp"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:layout_weight="2">
<TextView
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Label5: "
/>
<EditText
android:layout_weight="1"
android:id="#+id/editLabel5"
android:textColor="#C0C0C0"
android:layout_width="75dp"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:layout_weight="2">
<TextView
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Label6: "
/>
<EditText
android:layout_weight="1"
android:id="#+id/editLabel6"
android:textColor="#C0C0C0"
android:layout_width="75dp"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
This centers the linearlayout horizontally and vertically, however the columns are not lined up when the textViews have variable length text. I want to use a tablelayout so that the columns are lined up like so:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
android:background="#drawable/home_background"
>
<RelativeLayout
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fillViewport="true"
android:gravity="center" >
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
>
<!-- 2 columns -->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:orientation="horizontal"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="HEading1"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Heading2"
/>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Label1: "
/>
<EditText
android:id="#+id/editLabel1"
android:textColor="#C0C0C0"
android:layout_width="75dp"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Label2: "
/>
<EditText
android:id="#+id/editLabel2"
android:textColor="#C0C0C0"
android:layout_width="75dp"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Lable3: "
/>
<EditText
android:id="#+id/editLAble3"
android:textColor="#C0C0C0"
android:layout_width="75dp"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="LAbel4: "
/>
<EditText
android:id="#+id/editLabel4"
android:textColor="#C0C0C0"
android:layout_width="75dp"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Label5: "
/>
<EditText
android:id="#+id/editLable5"
android:textColor="#C0C0C0"
android:layout_width="75dp"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Lablel6: "
/>
<EditText
android:id="#+id/editLable6"
android:textColor="#C0C0C0"
android:layout_width="75dp"
android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
</RelativeLayout>
</ScrollView>
However, the tablelayout won't center horizontally. Also, in both layouts, the top portion of the layout (Headings and top of first row) is cut off when scrolling with the keyboard up. How can I center the tablelayout both horizontally and vertically and make it so the top portion of the layout is not cut off when scrolling?

Related

how to align fields in android?

Hi
I am making a simple example in android but My problem is that
my textview and editfield is not align.It mean that
it should look like that
![Name editView
Rollnumber editView
Button on center][2]
It look like this
here is my code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/text_view_boat1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
/>
<EditText
android:id="#+id/entry"
android:hint="add name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/text_view_boat2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Roll Number"
/>
<EditText
android:id="#+id/entry2"
android:hint="add roll number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me"
android:id="#+id/clickme"
/>
</LinearLayout>
Use TableLayout instead :
<LinearLayout 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"
android:orientation="vertical" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:shrinkColumns="1"
android:stretchColumns="1" >
<TableRow
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name :" />
<EditText
android:id="#+id/companyIdEditText_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:enabled="false"/>
</TableRow>
<TableRow
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RollNumber :" />
<EditText
android:id="#+id/companyNameEditText_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</TableRow>
</TableLayout>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="ClickMe"/>
</LinearLayout>
You can use the attribute weight. Set the the width of the row's chrildren to 0dp
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/text_view_boat2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Roll Number"
/>
<EditText
android:id="#+id/entry2"
android:hint="add roll number"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="2"
/>
</LinearLayout>
try this one...
<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" >
<TextView
android:id="#+id/text_view_boat1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="05dp"
android:text="Name" />
<EditText
android:id="#+id/entry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/text_view_boat1"
android:layout_marginRight="05dp"
android:layout_toRightOf="#id/text_view_boat1"
android:hint="add name" />
<LinearLayout
android:id="#+id/lin_lay"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/entry"
android:layout_marginTop="05dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/text_view_boat2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Roll Number" />
<EditText
android:id="#+id/entry2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="add roll number" />
</LinearLayout>
<Button
android:id="#+id/clickme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/lin_lay"
android:layout_marginTop="05dp"
android:text="Click Me" />

How to align ImageView & TextView align right in a Linear Layout

I would like show my Page view header like below,
I'm using the following layout using, but the image and second textview not moving to right, its all align center.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="6"
android:background="#drawable/transbg"
android:gravity="center"
android:orientation="vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="6"
android:gravity="center"
>
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:src="#drawable/yellow2" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</LinearLayout>
</TableRow>
</LinearLayout>
</LinearLayout>
how I can align one image view and textview right aligned.
Check out this one and let me know if it is what you want.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:background="#drawable/ic_launcher"
android:gravity="center"
android:orientation="vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:background="#android:color/black"
android:gravity="center" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:src="#drawable/ic_launcher"
android:layout_toLeftOf="#+id/tvCredits" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</RelativeLayout>
</TableRow>
</LinearLayout>
EDIT : If you want to make the same layout with easier and more efficient way, you can use this one.
<?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:background="#android:color/black" >
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/tvCredits"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</RelativeLayout>
// try this way
<?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="wrap_content"
android:gravity="center"
android:padding="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtName"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Magasin"
android:textColor="#FFF"
android:gravity="center"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"
android:adjustViewBounds="true"/>
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test"
android:textColor="#fff"
android:textSize="16sp"
android:layout_marginLeft="5dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="right">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="6"
android:background="#drawable/transbg"
android:gravity="center"
android:orientation="vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="6"
android:gravity="center"
>
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="right|center"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:src="#drawable/yellow2" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</LinearLayout>
</TableRow>
</LinearLayout>
</LinearLayout>
</LinearLayout>

Layout Weight in Linear Layout Android?

I am using two ListView in my Layout. and having fixed header and footer.But when i am running my code my header is getting breaked not coming full on my Device and my footer is not showing because of the ListView .
This is my main XML file that is having the ListView
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/llHeader"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1">
<LinearLayout
android:id="#+id/mainLinearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#drawable/top_bg"
android:orientation="horizontal" >
<ImageView
android:id="#+id/back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/back_btn"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="75dp"
android:text="Flights"
android:textColor="#android:color/white" />
</LinearLayout>
<LinearLayout
android:id="#+id/flightDetailsLayout"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_below="#+id/mainLinearLayout"
android:layout_centerHorizontal="true"
android:background="#drawable/gray_bg123"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/innerflightDetailsLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:paddingLeft="12dp"
android:textSize="12sp"
android:text="Boston to San Fransisco, "
android:textStyle="bold" />
<TextView
android:id="#+id/tripType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="RoundTrip"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/innerTripLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tripDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="12dp"
android:textSize="10sp"
android:text="19 Jan 2013 "
android:textStyle="bold"/>
<TextView
android:id="#+id/paxText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="for 1 Adults,0 Childs,O Infants"
android:textSize="12dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/Book"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/tripDate"
android:layout_width="84dp"
android:layout_height="wrap_content"
android:paddingLeft="12dp"
android:text="Rs 10,2345 "
android:textSize="10sp"
android:layout_weight="1"
android:textStyle="bold" />
<ImageView
android:id="#+id/bookBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:src="#drawable/book" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/sortFlightLayouts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/flightDetailsLayout"
android:background="#drawable/gray_bg123"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DEL-BLR"
android:layout_marginLeft="6dp"
android:layout_marginTop="5dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:src="#drawable/flight_icon_result" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="25dp"
android:src="#drawable/time" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:src="#drawable/rupee" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="60dp"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/gray_bg123"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BLR-DEL"
android:layout_marginLeft="6dp"
android:layout_marginTop="5dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:src="#drawable/flight_icon_result" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="25dp"
android:src="#drawable/time" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:src="#drawable/rupee" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="4"
android:orientation="horizontal">
<ListView
android:id="#+id/lvDepartures"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
<ListView
android:id="#+id/lvArrivals"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</LinearLayout>
<LinearLayout
android:id="#+id/llFooter"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"/>
<LinearLayout
android:id="#+id/footerLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:background="#drawable/top_bg" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_marginTop="5dp"
android:src="#drawable/filter" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_marginTop="5dp"
android:src="#drawable/sort" />
</LinearLayout>
</LinearLayout>
And this my Layout that i am putting in the ListView at RunTime
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/flightLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="5sp"
android:layout_marginRight="10sp"
android:layout_marginTop="5sp"
android:src="#drawable/spicejet" />
<TextView
android:id="#+id/flightCompanyName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/flightLogo"
android:text="Spice Jet" />
<TextView
android:id="#+id/flightNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/flightCompanyName"
android:text="9W-123" />
<TextView
android:id="#+id/flightTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/flightLogo"
android:gravity="center_vertical"
android:text="6:00 - 7:00" />
<TextView
android:id="#+id/flightStop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/flightTime"
android:layout_toRightOf="#+id/flightLogo"
android:text="1h 35m | Non Stop" />
<TextView
android:id="#+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/flightStop"
android:layout_toRightOf="#+id/flightLogo"
android:text="Rs 20,000" />
</RelativeLayout>
I can't tell if this is your only problem yet but when you use layout_weight inside of a vertical LinearLayout then your layout_height should be 0dp.
Likewise if it is inside of a horizontal LinearLayout then the layout_width should be 0dp. Also, all of the layouts should have a weight if you are using it on one of thenm.
android:layout_below= in your third LinearLayout, I believe, is not a property of LinearLayout. That is a property of RelativeLayout.
My suggestion for this type of setup is to use RelativeLayout as the root layout. Then, for your header LinearLayout you can use android:layout_alignParentTop="true" and for your footer use android:layout_alignParentBottom="true" then stick your ListView in the middle with android:layout_below="#id/idOfHeaderLL"
<RelativeLayout
...>
<LinearLayout
android:id="#+id/headerLL"
android:layout_alignParentTop="true"
...>
<!-- add header veiws -->
</LinearLayout
<ListView
android:layout_below="#id/headerLL"
.../>
<LinearLayout
android:layout_alignParentBottom="true"
...>
<!-- add footer views -->
</LinearLayout>
</RelativeLayout>
I'm not going to rewrite the whole layout but that should give you an idea. The "..." is where you will put in your other properties such as height, width, etc...

Android Horizontal Scroll View

i have a layout having many fields and i wish to add scrollbars for both horizontal and vertical layout.But vertical scroll is working horizontal scroll is not working.I have loaded the text fields dynamically in program and add the fields with web service .
My Activity
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LayoutScroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal|vertical" >
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="30dp"
android:gravity="fill|fill_horizontal"
android:orientation="vertical" >
<TableRow
android:id="#+id/Row_User_Deletion"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#DF0101"
android:gravity="center" >
<TextView
android:id="#+id/user_creation_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/txt_delete_user_userDeletion"
android:textColor="#color/white"
android:textSize="15dp" />
</TableRow>
<TableRow
android:id="#+id/RowUserType"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp" >
<TextView
android:id="#+id/txt_delete_user_selectuserType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="#string/txt_delete_user_selectuserType"
android:textColor="#424242" />
<Spinner
android:id="#+id/spin_delete_userType"
android:layout_width="120dp"
android:layout_height="50dp"
android:layout_marginBottom="5dp"
android:entries="#array/utype" />
<Button
android:id="#+id/btn_spinner_user_search_select"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginTop="5dp"
android:background="#drawable/redbtn"
android:text="#string/btn_delete_user_search_user" />
</TableRow>
<TableRow
android:id="#+id/deleteUserRow"
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_marginTop="10dp"
android:gravity="fill" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/txt_user_creation_userId"
android:textColor="#424242" />
<EditText
android:id="#+id/txt_user_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="55dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="#drawable/redbtn"
android:text="#string/btn_delete_user_search_user" />
</TableRow>
<TableLayout
android:id="#+id/delete_userDetails_Table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:stretchColumns="*" >
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:background="#color/red" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_delete_user_select"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView3"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_user_creation_userId"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView4"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_user_creation_userName"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_delete_user_UserRole"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/txt_componentmaster_createdDate"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/txt_componentmaster_createdBy"
android:textColor="#color/white" />
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
ImageView
Please keep in mind that the view that you want to scroll Horizontal is must have LinearLayout as parent then only you can set the HorizontalScrollView between that layout.
And Put one HorizontalScrollView as the Parent of those both LinearLayout.
Hope this will help you.
Smple:
<HORIZONTAL_VIEW ... >
<!-- Your First Layout -->
<LinearLayout ... >
</LinearLayout>
<!-- Your Second Layout -->
<LinearLayout ... >
</LinearLayout>
</HORIZONTAL_VIEW ... >
Hope you got my point.
Feel free for any query. :)
Try the Scroll Bars with out the Scrollview..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="30dp"
android:gravity="fill|fill_horizontal"
android:scrollbars="horizontal|vertical"
android:orientation="vertical" >
<TableRow
android:id="#+id/Row_User_Deletion"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#DF0101"
android:gravity="center" >
<TextView
android:id="#+id/user_creation_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/txt_delete_user_userDeletion"
android:textColor="#color/white"
android:textSize="15dp" />
</TableRow>
<TableRow
android:id="#+id/RowUserType"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp" >
<TextView
android:id="#+id/txt_delete_user_selectuserType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="#string/txt_delete_user_selectuserType"
android:textColor="#424242" />
<Spinner
android:id="#+id/spin_delete_userType"
android:layout_width="120dp"
android:layout_height="50dp"
android:layout_marginBottom="5dp"
android:entries="#array/utype" />
<Button
android:id="#+id/btn_spinner_user_search_select"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginTop="5dp"
android:background="#drawable/redbtn"
android:text="#string/btn_delete_user_search_user" />
</TableRow>
<TableRow
android:id="#+id/deleteUserRow"
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_marginTop="10dp"
android:gravity="fill" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/txt_user_creation_userId"
android:textColor="#424242" />
<EditText
android:id="#+id/txt_user_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="55dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="#drawable/redbtn"
android:text="#string/btn_delete_user_search_user" />
</TableRow>
<TableLayout
android:id="#+id/delete_userDetails_Table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:stretchColumns="*" >
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:background="#color/red" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_delete_user_select"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView3"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_user_creation_userId"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView4"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_user_creation_userName"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_delete_user_UserRole"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/txt_componentmaster_createdDate"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/txt_componentmaster_createdBy"
android:textColor="#color/white" />
</TableRow>
</TableLayout>
</LinearLayout>

android tablelayout with complex component placement

EDITED: I HAVE FOUND THE SOLUTION MYSELF. THANK YOU!
I want to create the following screen for an Android App:
Right now I have this:
with this code:
<?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="horizontal"
android:weightSum="1" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight=".65"
android:weightSum="5" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TOURNAMENT: "
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="1"
android:layout_marginLeft="10dp"/>
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="GAME: "
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="1"
android:layout_marginLeft="10dp" />
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="BEST OF: "
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="1"
android:layout_marginLeft="10dp" />
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="BRACKET STYLE: "
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="1"
android:layout_marginLeft="10dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight=".35"
android:weightSum="5" >
<EditText
android:id="#+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="10dp" />
<EditText
android:id="#+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="10dp" />
<EditText
android:id="#+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="10dp" />
<EditText
android:id="#+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="10dp" />
<RelativeLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1" >
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:text="CANCEL" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/button2"
android:text="CREATE" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
The text can be aligned to the right using android:gravity="right", but how can I make it
centered vertically?
--> AISHH, it's: android:gravity="center_vertical|right"
Thank you!!
Well TableLayout is not a good ideea. You should try using a RelativeLayout and some LinearLayout nested inside.
Try something like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:id="#+id/first_linear"
android:orientation="vertical">
<!-- Note that for text view,and editText you might need to use certain values (dip values) cuz wrap content will try to arrange the view -->
<TextView
android:id="#+id/first_text_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<EditText
android:id = "#+id/first_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<!-- we align all the following linearlayouts below the first -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/first_linear"
android:id="#+id/second_linear"
android:orientation="vertical">
<TextView
android:id="#+id/second_text_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<EditText
android:id = "#+id/second_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<!-- add all the layouts like those from above -->
<!-- ...... -->
<!-- after you added all the fields you can add a linear layout containing two buttons to float below the last one -->
I've done a similar layout like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"
android:layout_height="fill_parent" android:layout_width="fill_parent"
>
<ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1.0">
<LinearLayout android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="fill_parent">
<TableLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:stretchColumns="1" android:shrinkColumns="1">
<TableRow android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:text="Value1" android:gravity="right" />
<EditText android:singleLine="true" android:id="#+id/editTextVal1" />
</TableRow>
<TableRow android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:text="Long name value2" android:gravity="right" />
<EditText android:singleLine="true" android:id="#+id/editTextVal1" />
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0.0">
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Save" />
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Cancel" />
</LinearLayout>
</LinearLayout>
There's a scroll panel in there to have the buttons on the bottom of the screen at all times, in case your configuration goes longer.
So this is the implementation I came up with. Not the best but worked for me :)
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight=".65"
android:weightSum="5"
android:paddingTop="10dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TOURNAMENT: "
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:gravity="center_vertical|right"/>
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="GAME: "
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:gravity="center_vertical|right"/>
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="BEST OF: "
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:gravity="center_vertical|right"/>
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="BRACKET STYLE: "
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:gravity="center_vertical|right"/>
<!-- fill up the space so that the components on top are displayed correctly -->
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:gravity="center_vertical|right"/>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight=".35"
android:weightSum="5"
android:paddingTop="10dp" >
<EditText
android:id="#+id/tourName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="10dp"
android:gravity="center_vertical|left" />
<Spinner
android:id="#+id/spinGameName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="10dp"
android:gravity="center_vertical|left" />
<Spinner
android:id="#+id/spinBestOf"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="10dp"
android:gravity="center_vertical|left" />
<Spinner
android:id="#+id/spinBracketType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="10dp"
android:gravity="center_vertical|left" />
<RelativeLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1" >
<Button
android:id="#+id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:text="CANCEL" />
<Button
android:id="#+id/btnCreate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/btnCancel"
android:text="CREATE" />
</RelativeLayout>
</LinearLayout>

Categories

Resources