2

嗨,我正在尝试创建一个联赛表,其中我有几个不同的观点问题是俱乐部的名称会根据名称的大小将其余观点推到上面是否有一种方法可以对齐所有内容,使其对齐向上和/或限制名称的长度?

这就是我要找的东西

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>
4

1 回答 1

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>

在此处输入图像描述

于 2012-06-28T14:58:58.087 回答