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.xmlEdit: 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"?>
开发者_JAVA百科<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>
精彩评论