how to design view layout in vertical on android - android

hi all
i need to design view layout between two linear layout. i see view's property for orientation. i want to put view layout by vertically between linear layout2 and linear layout3. please assist me.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:id="#+id/linearLayout1" android:layout_height="wrap_content">
<LinearLayout android:layout_width="wrap_content"
android:id="#+id/linearLayout2" android:layout_height="wrap_content">
<TextView android:text="TextView" android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:id="#+id/linearLayout3" android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:text="TextView" android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView android:text="TextView" android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</LinearLayout>
</LinearLayout>

In Your layout XML file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:id="#+id/linearLayout1" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="wrap_content"
android:id="#+id/linearLayout2" android:layout_height="wrap_content">
<TextView android:text="TextView" android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:id="#+id/linearLayoutNEW" android:layout_height="wrap_content">
<TextView android:text="TextView" android:id="#+id/textViewNEW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:id="#+id/linearLayout3" android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:text="TextView" android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView android:text="TextView" android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</LinearLayout>
Now You have three LinearLayout with horizontal orientation one under another... Is this what you wanted to achieve?
And it is even not recommended to use LinearLayout when only one control is within it...
So next example should be better:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:id="#+id/linearLayout1" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text="TextView" android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
<LinearLayout android:layout_width="wrap_content" android:orientation="vertical"
android:id="#+id/linearLayoutNEW" android:layout_height="wrap_content">
<TextView android:text="TextView" android:id="#+id/textViewNEW1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
<TextView android:text="TextView" android:id="#+id/textViewNEW2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:id="#+id/linearLayout3" android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:text="TextView" android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView android:text="TextView" android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</LinearLayout>

Related

Centering a linearlayout present inside a listview

I have a listview which contains a linearlayout. I am trying to get the linearlayout to the center of the screen(horizontally) but it doesn't work.
How it looks -
Portrait -
Landscape -
I want the linearlayout(which has the text "text" and the two images) to come to the center of the screen(horizontally) in both the orientations.
I've tried using layout_gravity on the linearlayout but it doesn't work.
Here's my 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="match_parent"
android:orientation="vertical"
android:background="#EEEEEE" >
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/parentListContainer">
</ListView>
</LinearLayout>
Each listview item -
<?xml version="1.0" encoding="utf-8"?>
<!-- I want this layout centered. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textColor="#000000"
android:text="text"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/ivBottle1"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"/>
<TextView
android:id="#+id/tvBottle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textSize="22sp" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/ivBottle2"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"/>
<TextView
android:id="#+id/tvBottle2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textSize="22sp" >
</TextView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Please help.
EDIT: Neither gravity="center" works on the listview, nor does layout_gravity="center" on the linearlayout.
<?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="match_parent"
android:orientation="vertical"
android:background="#EEEEEE" >
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="#+id/parentListContainer">
</ListView>
</LinearLayout>
See here for explanation : https://stackoverflow.com/a/3482757/4706693
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textColor="#000000"
android:text="text"/>
<LinearLayout
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/ivBottle1"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"/>
<TextView
android:id="#+id/tvBottle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textSize="22sp" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/ivBottle2"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"/>
<TextView
android:id="#+id/tvBottle2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textSize="22sp" >
</TextView>
</LinearLayout>
</LinearLayout>

Text overlapping in Android text view

I am facing a strange behavior of text view. When the text view has multiple lines, the lines are overlapping on each other. I tried to solve it but didn't get any clue yet.
Here is the 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="fill_parent"
android:background="#drawable/googletv_bkgd_no_title"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="85dip"
android:gravity="center_vertical"
android:orientation="horizontal" >
<FrameLayout
android:id="#+id/frameLayout1"
android:layout_width="fill_parent"
android:layout_height="match_parent" android:paddingRight="50dip">
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="right|center_vertical" android:gravity="center_vertical">
<TextView
android:id="#+id/navigationHeaderTxtView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#cccccc"
android:visibility="gone" android:layout_gravity="center_vertical"/>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" android:layout_gravity="left|center_vertical" android:layout_marginLeft="5dip" android:textColor="#ebebee" android:textStyle="bold"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
<!--
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="top|right" android:layout_marginRight="20dip">
<Button
android:id="#+id/btnBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:background="#drawable/btn_back" />
<Button
android:id="#+id/btnHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:background="#drawable/btn_home" />
</LinearLayout>-->
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" android:layout_gravity="top" android:layout_marginTop="20dip" android:gravity="center">
<ImageView
android:id="#+id/arrow_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/arrow_up" android:visibility="visible"/>
</LinearLayout>
<FrameLayout
android:id="#+id/frameLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:paddingLeft="80dip" android:paddingRight="80dip">
<GridView
android:id="#+id/gridView1"
android:layout_width="match_parent"
android:layout_height="250dip"
android:cacheColorHint="#00000000"
android:horizontalSpacing="10dip"
android:listSelector="#drawable/list_selector"
android:numColumns="5"
android:padding="10dip"
android:verticalSpacing="10dip" >
</GridView>
</FrameLayout>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" android:layout_gravity="top" android:layout_marginTop="20dip" android:gravity="center">
<ImageView
android:id="#+id/arrow_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/arrow_down" android:visibility="visible"/>
</LinearLayout>
<LinearLayout
android:id="#+id/frameLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/title_color"
android:textSize="25dip" android:layout_gravity="center_horizontal"/>
<TextView
android:id="#+id/textDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
I have attached a screenshot regarding the problem.
How do I fix this?
You will need to adjust your line spacing to accommodate the odd custom font, such as android:lineSpacingExtra on your TextView.

converting a xml into a custom widget in android

here is my xml which i want to convert into a widget. Basically what i am doing is that inflating a layout multiple times based on user inside a loop its working bt the problem is its taking too long to inflate and application crashes if a user enters a double digit no. as input .Thats y i want to convert that layout into a widget so that i can inflate it once outside loop and then add continously inside loop. right nw i m inflating evry time inside loop before adding it.
<?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="match_parent"
android:layout_height="match_parent">
<LinearLayout android:layout_width="fill_parent"
android:id="#+id/Main_linearLayout" android:layout_height="wrap_content">
<RelativeLayout android:id="#+id/Number_relativeLayout"
android:layout_height="wrap_content" android:layout_width="50dip"
android:background="#drawable/left">
<RelativeLayout android:id="#+id/num_Lyout"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" android:background="#drawable/measureno">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/num_txt"
android:textStyle="bold" android:layout_centerHorizontal="true"
android:layout_centerVertical="true" android:textColor="#000000"></TextView>
</RelativeLayout>
</RelativeLayout>
<LinearLayout android:layout_height="match_parent"
android:orientation="vertical" android:layout_width="fill_parent"
android:id="#+id/Right_Main_Content">
<LinearLayout android:layout_height="wrap_content"
android:layout_width="match_parent" android:id="#+id/Upper_Right_Main_Content"
android:background="#drawable/big">
<LinearLayout android:layout_height="match_parent"
android:layout_width="0dp" android:layout_weight="1"
android:id="#+id/Left_Upper_Right_Content">
<RelativeLayout android:layout_height="match_parent"
android:id="#+id/relativeLayout2" android:layout_width="match_parent"
android:padding="10dp">
<LinearLayout android:layout_height="wrap_content"
android:id="#+id/linearLayout4" android:layout_centerVertical="true"
android:layout_centerHorizontal="true" android:layout_width="match_parent">
<TextView android:id="#+id/textView1"
android:layout_height="wrap_content" android:text="A(ft.)"
android:layout_width="wrap_content" android:textColor="#076663"
android:textStyle="bold"></TextView>
<EditText android:id="#+id/editText1"
android:layout_height="wrap_content" android:layout_weight="1"
android:layout_width="0dp" android:background="#drawable/textareabg">
<requestFocus></requestFocus>
</EditText>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout android:layout_height="match_parent"
android:layout_weight="1" android:layout_width="0dp"
android:id="#+id/Right_Upper_Right_Content">
<RelativeLayout android:layout_height="match_parent"
android:id="#+id/RelativeLayout01" android:layout_width="match_parent"
android:padding="10dp">
<LinearLayout android:layout_width="match_parent"
android:layout_centerHorizontal="true" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:id="#+id/LinearLayout01">
<TextView android:layout_height="wrap_content"
android:id="#+id/TextView01" android:text="A(in.)"
android:layout_width="wrap_content" android:textColor="#076663"
android:textStyle="bold"></TextView>
<EditText android:id="#+id/EditText01"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_weight="1" android:background="#drawable/textareabg"></EditText>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<RelativeLayout android:id="#+id/wrapper_bottom"
android:layout_height="wrap_content" android:layout_width="wrap_content">
<LinearLayout android:id="#+id/LinearLayout1"
android:layout_width="match_parent" android:background="#drawable/bottomthis"
android:layout_height="wrap_content">
<RadioGroup android:layout_height="wrap_content"
android:orientation="horizontal" android:id="#+id/radioGroup"
android:layout_weight="1" android:layout_width="0dp">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="#076663"
android:id="#+id/textView5" android:text="Obstruction"></TextView>
<RadioButton android:layout_height="wrap_content"
android:layout_width="wrap_content" android:button="#drawable/redio_on"
android:checked="true" android:id="#+id/radio_Obstruction_a"></RadioButton>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="#076663"
android:id="#+id/textView6" android:text="Raisedwall"></TextView>
<RadioButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:button="#drawable/rediooff"
android:id="#+id/radio_Raisedwall_a"></RadioButton>
</RadioGroup>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

How can i setup this layout?

I would like to make a rather complex layout. Can someone help me, as how to do my layout.xml ?
Layout image
No. 1 is a Layout (Table, Linear etc)
No. 2 is my listview, containing a row of list_details.xml
Edit: so far I managed to do the first part
<TableLayout android:layout_height="wrap_content" android:layout_width="fill_parent">
<TableRow android:layout_width="wrap_content" android:stretchColumns="0,2" android:layout_marginTop="2sp" android:layout_height="wrap_content" >
<TextView android:id="#+id/homeTeam" android:layout_weight="2" android:paddingRight="4sp"/>
<TextView android:text="Vs" android:layout_weight="0" />
<TextView android:id="#+id/awayTeam" android:layout_weight="2" android:gravity="right" android:paddingLeft="4sp"/>
</TableRow>
</TableLayout>
<ListView android:id="#id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ListView>
EDIT:
Well i probably didn't explain well what i want to do. Here is a screenshot of my app
My current layout
I want the columns to align. So far i am using this xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:stretchColumns="0,4" xmlns:android="http://schemas.android.com/apk/res/android">
<TableRow android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="#+id/ll_playerHome" android:layout_weight="0.5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="12sp"/>
<ImageView android:id="#+id/ll_eventHome" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<TextView android:id="#+id/ll_minute" android:layout_weight="0" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<ImageView android:id="#+id/ll_eventAway" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<TextView android:id="#+id/ll_playerAway" android:layout_weight="0.5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:textSize="12sp"/>
</TableRow>
</TableLayout>
This might do the trick:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="#+id/linearLayout1">
<TextView android:layout_width="wrap_content" android:text="TextView"
android:id="#+id/textView1" android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_height="wrap_content" android:layout_weight="1"
android:gravity="center_horizontal"></TextView>
<TextView android:text="TextView" android:id="#+id/textView2"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal"></TextView>
<TextView android:layout_width="wrap_content" android:text="TextView"
android:id="#+id/textView3" android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_height="wrap_content" android:layout_weight="1"
android:gravity="center_horizontal"></TextView>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="#+id/linearLayout2">
<ListView android:layout_height="wrap_content" android:id="#+id/listView1"
android:layout_weight="1" android:layout_width="fill_parent"></ListView>
<TextView android:text="TextView" android:id="#+id/textView2"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal"></TextView>
<ListView android:layout_height="wrap_content" android:id="#+id/listView1"
android:layout_weight="1" android:layout_width="fill_parent"></ListView>
</LinearLayout>
</LinearLayout>

How to draw this LinearLayout in Android?

I would like to realize a LinearLayout in Android like this:
{ deleted image }
but I don't know how to do.
If I do:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="60dp" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="60dp" >
<TextView android:text="TextView" android:id="#+id/item_0"
android:layout_width="wrap_content"
android:layout_height="30dp" >
</TextView>
<TextView android:text="TextView" android:id="#+id/item_1"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:textSize="18dp"
android:textColor="#ff0000">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="80dp"
android:gravity="right"
android:layout_height="60dp" >
<TextView android:text="TextView" android:id="#+id/item_2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
android:textColor="#ff0000">
</TextView>
</LinearLayout>
</LinearLayout>
The second LinearLayout (on the right) is not shown. I think I would have to use a RelativeLayout, but how can I draw a similar LinearLayout?
This is the layout used for a ListItem in a ListView so every box has to have the same width (hence cannot use wrap_content for the 2 item_0 and item_1 layout wrapper.
Try adding android:layout_weight="1" to your first child LinearLayout inside the top level LinearLayout (i.e. the one on the 5th line of your XML):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="60dp">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="60dp" android:layout_weight="1">
<TextView android:text="TextView" android:id="#+id/item_0"
android:layout_width="wrap_content" android:layout_height="30dp">
</TextView>
<TextView android:text="TextView" android:id="#+id/item_1"
android:layout_width="wrap_content" android:layout_height="30dp"
android:textSize="18dp" android:textColor="#ff0000">
</TextView>
</LinearLayout>
<LinearLayout android:layout_width="80dp" android:gravity="right"
android:layout_height="60dp">
<TextView android:text="TextView" android:id="#+id/item_2"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textSize="20dp" android:textColor="#ff0000">
</TextView>
</LinearLayout>
</LinearLayout>
<?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="60dp" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:layout_weight="70">
<TextView android:text="TextView" android:id="#+id/item_0"
android:layout_width="wrap_content"
android:layout_height="30dp" >
</TextView>
<TextView android:text="TextView" android:id="#+id/item_1"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:textSize="18dp"
android:textColor="#ff0000">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_weight="30"
android:layout_width="80dp"
android:gravity="right"
android:layout_height="60dp" >
<TextView android:text="TextView" android:id="#+id/item_2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
android:textColor="#ff0000">
</TextView>
</LinearLayout>
</LinearLayout>
http://developer.android.com/resources/articles/layout-tricks-efficiency.html
so more efficient way will be this layout:
<?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="60dp">
<TextView android:text="TextView" android:id="#+id/item_2"
android:layout_width="80dp" android:layout_alignParentTop="true"
android:layout_height="60dp" android:textSize="20dp"
android:textColor="#ff0000" android:layout_alignParentRight="true">
</TextView>
<TextView android:text="TextView" android:id="#+id/item_0"
android:layout_width="fill_parent" android:layout_height="30dp"
android:layout_toLeftOf="#id/item_2">
</TextView>
<TextView android:text="TextView" android:id="#+id/item_1"
android:layout_width="fill_parent" android:layout_height="30dp"
android:textSize="18dp" android:textColor="#ff0000"
android:layout_below="#id/item_0" android:layout_toLeftOf="#id/item_2">
</TextView>
</RelativeLayout>

Categories

Resources