Android ListView - football table with different cell width
I've done a lot of research but havent't found a solution for my Android ListView problem!
My layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ListView android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
In this ListView I'd like to display a football table where the coloumns have different width (e.g. team title should be wider than points)! Therefore I created the following row-layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/team_line"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="3dip"
android:orientation="horizontal">
<TextView
android:id="@+id/team_place"
android:layout_width="30dip"
android:layout_height="fill_parent"
android:gravity="right"
android:textColor="#d08021"
android:paddingRight="6dip"
/>
<TextView
android:id="@+id/team_name"
android:layout_width="140dip"
android:layout_height="fill_parent"
android:layout_weight="1" />
<TextView
开发者_StackOverflow社区android:id="@+id/team_games"
android:gravity="right"
android:layout_width="30dip"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<TextView
android:id="@+id/team_games_win"
android:gravity="right"
android:layout_width="30dip"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<TextView
android:id="@+id/team_games_draw"
android:gravity="right"
android:layout_width="30dip"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<TextView
android:id="@+id/team_games_loose"
android:gravity="right"
android:layout_width="30dip"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<TextView
android:id="@+id/team_goals_shot"
android:gravity="right"
android:layout_width="30dip"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<TextView
android:id="@+id/team_goals_got"
android:gravity="right"
android:layout_width="30dip"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<TextView
android:id="@+id/team_points"
android:gravity="right"
android:layout_width="40dip"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
</LinearLayout>
The ListView works in normal mode, but in Landscape mode the full screen size isn't used! I don't know if my layout_width properties are right. What is the maximal size (in dip) I can use?
I tried to use different layout_width parameters with different layout_width values but haven't got a solution yet.
What is the best way to get the "cells" of my listview aligned properly with different width for normal and landscape mode? Isn't there a possible way of using percentage values?
I hope anyone can help me!
Thanks in advance!
Best regards, Daniel
精彩评论