列表原始详细信息 - android

时间:2013-12-03 09:58:02

标签: android xml android-layout android-listview

现在我正在使用自定义列表视图构建应用程序,以支持超过设备规模

这是我的代码

list_raw

<?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="?android:attr/listPreferredItemHeight"
    android:background="@drawable/table_2"
    android:orientation="horizontal"
   >

<LinearLayout
    android:id="@+id/date"
    android:layout_width="77dip"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:gravity="center"
    >

    <TextView
        android:id="@+id/textView5"
        android:gravity="center"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:text="1/12/2013"
        android:textColor="#FFFFFF" />

</LinearLayout>

 <LinearLayout
     android:id="@+id/match"
     android:layout_width="116dip"
     android:layout_height="fill_parent"
     android:layout_alignParentBottom="true"
     android:layout_alignParentTop="true"
     android:layout_toLeftOf="@+id/date"
     android:layout_toRightOf="@+id/place" >

    <LinearLayout
         android:layout_width="49dip"
         android:layout_height="fill_parent"
         android:orientation="vertical" >

         <ImageView
             android:id="@+id/imageView1"
             android:layout_width="match_parent"
             android:layout_height="40dip"
             android:gravity="center"
             android:src="@drawable/pic" />

         <TextView
             android:id="@+id/textView4"
             android:layout_width="fill_parent"
             android:layout_height="12dip"
             android:gravity="center"
             android:text="Ahly"
             android:textColor="#FFFFFF"
             android:textSize="10dip" />
     </LinearLayout>

     <TextView
         android:id="@+id/textView3"
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
         android:gravity="center_vertical"
         android:text="VS"
         android:textColor="#FFFFFF" />

     <LinearLayout
         android:layout_width="49dip"
         android:layout_height="fill_parent"
         android:orientation="vertical">

         <ImageView
             android:id="@+id/imageView1"
             android:layout_width="wrap_content"
             android:layout_height="40dip"
             android:gravity="center"
             android:src="@drawable/pic" />

         <TextView
             android:id="@+id/textView4"
             android:layout_width="match_parent"
             android:layout_height="12dip"
             android:gravity="center"
             android:text="liverpool"
             android:textColor="#FFFFFF"
             android:textSize="10dip" />

     </LinearLayout>
 </LinearLayout>

 <LinearLayout
     android:id="@+id/place"
     android:layout_width="46dip"
     android:layout_height="fill_parent"
     android:layout_alignParentBottom="true"
     android:layout_alignParentTop="true"
     android:layout_toRightOf="@+id/textView1"
     android:gravity="center_horizontal"
     android:orientation="horizontal" >

     <TextView
         android:id="@+id/textView2"
         android:layout_width="wrap_content"
         android:layout_height="fill_parent"
         android:gravity="center"
         android:text="Out"
         android:textColor="#FFFFFF" />
 </LinearLayout>

 <TextView
     android:id="@+id/textView1"
     android:layout_width="76dip"
     android:layout_height="fill_parent"
     android:layout_alignParentBottom="true"
     android:layout_alignParentLeft="true"
     android:layout_alignParentTop="true"
     android:gravity="center"
     android:text="Aljazeera"
     android:textColor="#FFFFFF" />

请我将所有文字和图片放在视图各部分的中心

3 个答案:

答案 0 :(得分:0)

试试这个..

<?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="?android:attr/listPreferredItemHeight"
    android:background="@drawable/table_2"
    android:orientation="horizontal"
   >

<LinearLayout
    android:id="@+id/date"
    android:layout_width="77dip"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:gravity="center"
    >

    <TextView
        android:id="@+id/textView5"
        android:gravity="center"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:text="1/12/2013"
        android:textColor="#FFFFFF" />

</LinearLayout>

 <LinearLayout
     android:id="@+id/match"
     android:layout_width="116dip"
     android:layout_height="fill_parent"
     android:gravity="center"
     android:layout_alignParentBottom="true"
     android:layout_alignParentTop="true"
     android:layout_toLeftOf="@+id/date"
     android:layout_toRightOf="@+id/place" >

    <LinearLayout
         android:layout_width="49dip"
         android:layout_height="fill_parent"
         android:gravity="center"
         android:layout_gravity="center"
         android:orientation="vertical" >

         <ImageView
             android:id="@+id/imageView1"
             android:layout_width="match_parent"
             android:layout_height="40dip"
             android:gravity="center"
             android:src="@drawable/pic" />

         <TextView
             android:id="@+id/textView4"
             android:layout_width="fill_parent"
             android:layout_height="12dip"
             android:gravity="center"
             android:text="Ahly"
             android:textColor="#FFFFFF"
             android:textSize="10dip" />
     </LinearLayout>

     <TextView
         android:id="@+id/textView3"
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
         android:gravity="center_vertical"
         android:text="VS"
         android:textColor="#FFFFFF" />

     <LinearLayout
         android:layout_width="49dip"
         android:layout_height="fill_parent"
         android:gravity="center"
         android:layout_gravity="center"
         android:orientation="vertical">

         <ImageView
             android:id="@+id/imageView1"
             android:layout_width="wrap_content"
             android:layout_height="40dip"
             android:gravity="center"
             android:src="@drawable/pic" />

         <TextView
             android:id="@+id/textView4"
             android:layout_width="match_parent"
             android:layout_height="12dip"
             android:gravity="center"
             android:text="liverpool"
             android:textColor="#FFFFFF"
             android:textSize="10dip" />

     </LinearLayout>
 </LinearLayout>

 <LinearLayout
     android:id="@+id/place"
     android:layout_width="46dip"
     android:layout_height="fill_parent"
     android:layout_alignParentBottom="true"
     android:layout_alignParentTop="true"
     android:layout_toRightOf="@+id/textView1"
     android:gravity="center_horizontal"
     android:orientation="horizontal" >

     <TextView
         android:id="@+id/textView2"
         android:layout_width="wrap_content"
         android:layout_height="fill_parent"
         android:gravity="center"
         android:text="Out"
         android:textColor="#FFFFFF" />
 </LinearLayout>

 <TextView
     android:id="@+id/textView1"
     android:layout_width="76dip"
     android:layout_height="fill_parent"
     android:layout_alignParentBottom="true"
     android:layout_alignParentLeft="true"
     android:layout_alignParentTop="true"
     android:gravity="center"
     android:text="Aljazeera"
     android:textColor="#FFFFFF" />
 </RelativeLayout>

答案 1 :(得分:0)

使用此功能,但将图像资源更改为您的..

<?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="?android:attr/listPreferredItemHeight"
    android:background="@color/green"
    android:orientation="horizontal" >

    <LinearLayout
        android:id="@+id/date"
        android:layout_width="77dip"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:gravity="center" >

        <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:text="1/12/2013"
            android:textColor="#FFFFFF" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/match"
        android:layout_width="116dip"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/date"
        android:layout_toRightOf="@+id/place" >

        <LinearLayout
            android:layout_width="49dip"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="match_parent"
                android:layout_height="40dip"
                android:gravity="center"
                android:src="@drawable/ic_launcher" />

            <TextView
                android:id="@+id/textView4"
                android:layout_width="fill_parent"
                android:layout_height="12dip"
                android:gravity="center"
                android:text="Ahly"
                android:textColor="#FFFFFF"
                android:textSize="10dip" />
        </LinearLayout>

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:gravity="center_vertical"
            android:text="VS"
            android:textColor="#FFFFFF" />

        <LinearLayout
            android:layout_width="49dip"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="40dip"
                android:gravity="center"
                android:src="@drawable/ic_launcher" />

            <TextView
                android:id="@+id/textView4"
                android:layout_width="match_parent"
                android:layout_height="12dip"
                android:gravity="center"
                android:text="liverpool"
                android:textColor="#FFFFFF"
                android:textSize="10dip" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/place"
        android:layout_width="46dip"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/textView1"
        android:gravity="center_horizontal"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:text="Out"
            android:textColor="#FFFFFF" />
    </LinearLayout>

    <TextView
        android:id="@+id/textView1"
        android:layout_width="76dip"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:gravity="center"
        android:text="Aljazeera"
        android:textColor="#FFFFFF" />

</RelativeLayout>

答案 2 :(得分:0)

使用这个:

<?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="match_parent"
  android:orientation="vertical" >

  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="10"

    android:orientation="horizontal" >

    <TextView
        android:id="@+id/textView2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:gravity="center"
        android:text="Aljazeera"
        android:textColor="#000" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:gravity="center"
        android:text="Out"
        android:textColor="#000" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/i1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:src="@drawable/ic_launcher" >
        </ImageView>

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="Ahly"
            android:textColor="#000" />
    </LinearLayout>

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="Vs" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/i2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:src="@drawable/ic_launcher" >
        </ImageView>

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="Liverpool"
            android:textColor="#000" />
    </LinearLayout>

    <TextView
        android:id="@+id/textView5"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:text="1/12/2013"
        android:textColor="#000" />
 </LinearLayout>

</LinearLayout>