2012-03-18 62 views
0

我爲自定義適配器使用以下xml佈局。使用imageview和textview的Android自定義適配器

<?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" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:text="TextView" /> 

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


    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="TextView" /> 

</LinearLayout> 

當我膨脹此自定義佈局(爲一個列表視圖)TextView的具有大的間隙怎麼一回事,因爲view.I希望能夠以顯示下面彼此的TextView和圖像視圖的右側的圖像的。我如何做到這一點。

+0

你不必'EditTexts'在佈局中。 – Luksprog 2012-03-18 13:53:18

+0

對不起,我的意思是textview – user1092042 2012-03-18 13:54:06

回答

1

使用Relativelayout

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 


    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:src="@drawable/ic_launcher" /> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toLeftOf="@id/imageView1" 
     android:layout_alignParentLeft="true" 
     android:text="TextView" /> 



    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/textView1" 
     android:layout_toLeftOf="@id/imageView1" 
     android:layout_alignParentLeft="true" 
     android:text="TextView" /> 

</RelativeLayout> 
相關問題