开发者

listview row custom layout problem

开发者 https://www.devze.com 2023-03-22 16:40 出处:网络
Hi i got the following code th开发者_开发百科at represents a row of my listview. <LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"

Hi i got the following code th开发者_开发百科at represents a row of my listview.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight">
  <LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1">
     <ImageView
        android:id="@+id/taxi_logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/puerta"
        android:layout_gravity="center" />
             <LinearLayout
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1">
                <TextView
                    android:id="@+id/item_id"
                    android:text="-1"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:visibility="gone"
                    android:layout_weight="1"/>
                <TextView
                    android:id="@+id/item_name"
                    android:text="PIDALO RADIO TAXI"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:textColor="#FFFF09"
                    android:textSize="20dip"                    
                    android:layout_weight="1"
                    android:singleLine="true"
                android:gravity="bottom"/>
                <TextView
                    android:id="@+id/item_phone"
                    android:text="(011)4-988-0680"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:textSize="14dip"
                    android:singleLine="true"
                    android:layout_weight="1"
                    android:gravity="top"/>
        </LinearLayout>
     <ImageView
        android:id="@+id/taxi_fav"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/no_star"
        android:layout_gravity="center_vertical"
        android:layout_marginRight="6dip"/>

    </LinearLayout>
</LinearLayout>

My problem is that between the two textviews ( item_name, item_phone ) there is a space even when the gravity of one is set to bottom and the other to top. I want the text of the item_name right on top of the item_phone, and right now there is a small gap.


Use this Layout instead:

<?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="fill_parent">
    <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content"
        android:src="@drawable/puerta" android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"></ImageView>
    <TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_toRightOf="@+id/imageView1"
        android:id="@+id/textView1" android:text="PILADO RADIO TAXI"
        android:textColor="#FFFF09" android:textSize="20dip"
        android:singleLine="true" android:layout_marginTop="5dip"
        android:gravity="bottom"></TextView>
    <TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:id="@+id/textView2"
        android:layout_alignLeft="@+id/textView1" android:layout_alignRight="@+id/textView1"
        android:text="(011)4-988-0680" android:textSize="14dip"
        android:singleLine="true" android:gravity="top"
        android:layout_marginTop="25dip"></TextView>
    <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content"
        android:src="@drawable/no_star" android:layout_height="wrap_content"
        android:layout_alignParentRight="true" android:layout_marginRight="30dip"></ImageView>

</RelativeLayout>
0

精彩评论

暂无评论...
验证码 换一张
取 消