android均匀空间视图

时间:2012-06-28 14:52:47

标签: android views

嗨我正在尝试创建一个联赛表,其中我有几个不同的视图问题是俱乐部的名称推动其余的视图取决于名称的大小是否有一种方式,我可以对齐一切它排列和/或限制名称的长度?

继承人我在寻找什么

1 Name.. 0 0 0 0 0 0 0
2 Name.. 0 0 0 0 0 0 0 
3 Name.. 0 0 0 0 0 0 0

继承人我在做什么

6 Name 0 0 0 0 0 0 0
7 Name 0 0 0 0 0 0 0 
8 Name 0 0 0 0 0 0 0
9 Name 0 0 0 0 0 0 0
10 Name 0 0 0 0 0 0 0 
11 Name 0 0 0 0 0 0 0

继承我的布局

    <?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" 
    android:background="@color/white">

    <TextView
        android:id="@+id/position"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight=".13"
        android:paddingLeft="10dp"
        android:text="0"

        android:layout_gravity="center_horizontal"
         android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/blue"
         />

    <TextView
        android:id="@+id/TeamName"
        android:layout_width="70dp"
        android:layout_height="wrap_content"
        android:ellipsize="end"
        android:lines="1"
        android:paddingLeft="5dp"
        android:text="Team Name"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textStyle="bold" 
        android:textColor="@color/blue"
         android:gravity="left"/>

    <TextView
        android:id="@+id/played"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".13"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium"
         android:textColor="@color/blue" 
          android:gravity="center"/>

    <TextView
        android:id="@+id/won"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium"
         android:textColor="@color/blue" 
          android:gravity="center"/>

    <TextView
        android:id="@+id/drawn"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".13"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium" 
         android:textColor="@color/blue"/>

    <TextView
        android:id="@+id/lost"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/drawn"
        android:layout_alignBottom="@+id/drawn"
        android:layout_toRightOf="@+id/drawn"
        android:layout_weight=".13"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium" 
         android:textColor="@color/blue"
          android:gravity="center"/>

    <TextView
        android:id="@+id/goalsFor"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium"
         android:textColor="@color/blue"
          android:gravity="center" />

    <TextView
        android:id="@+id/goalsAgainst"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".13"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium" 
         android:textColor="@color/blue"
          android:gravity="center"/>

    <TextView
        android:id="@+id/difference"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".13"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium"
         android:textColor="@color/blue"
          android:gravity="center" />

    <TextView
        android:id="@+id/points"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".13"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium"
         android:textColor="@color/blue"
          android:gravity="center" />

</LinearLayout>

1 个答案:

答案 0 :(得分:2)

如果可以使用线性布局

,请尝试此操作
<?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" >

    <TextView
        android:id="@+id/position"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".13"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/TeamName"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:ellipsize="end"
        android:lines="1"
        android:paddingLeft="10dp"
        android:text="Team Name"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/played"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".13"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/won"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/drawn"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".13"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/lost"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/drawn"
        android:layout_alignBottom="@+id/drawn"
        android:layout_toRightOf="@+id/drawn"
        android:layout_weight=".13"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/goalsFor"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/goalsAgainst"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".13"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/difference"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".13"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/points"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".13"
        android:paddingLeft="10dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</LinearLayout>

enter image description here