2013-12-16 98 views
0
I have a listview row.xml 
<?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"> 
<TextView android:id="@+id/text1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:paddingTop="10dp" 
    android:paddingLeft="5dp" 
    android:textSize="26sp" 
    android:textColor="@color/black" 
    android:layout_weight="3"/> 
<ImageView android:id="@+id/img" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:paddingTop="10dp" 
    android:layout_weight="1"/> 
</LinearLayout> 

它應該顯示一段文字和一張圖片。但它只顯示圖片。文本不顯示在文本/圖片列表視圖行中

+0

你是如何設置'text1'的文本? –

+0

via listview adapter – ceptno

回答

1

嘗試使用

是這樣的:

<TableRow xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:background="#FFF" 
      android:layout_height="wrap_content"> 

    <TextView android:id="@+id/something" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="2" 
       android:gravity="center" 
       android:textColor="#FFF" 
       android:textSize="16sp" 
       android:contentDescription="" 
       android:text="something"/> 

    <ImageView android:id="@+id/image" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:background="#FFF" 
       android:layout_weight="1" 
       android:contentDescription="" 
       android:layout_gravity="center_vertical" 
       android:src="@drawable/image"/> 

</TableRow> 

,也許你的LinearLayout是黑色的相同的TextView。不知道,通常它的工作原理..

+0

如何讓文字坐在最左邊,圖像坐在最右邊? – ceptno

+0

你可以在文本視圖上添加android:gravity =「left」,而在android:gravity =「right」上添加:D – mbarisa

0

兩個textviewimageview的變化android:layout_width="wrap_content"android:layout_width="0dp"

相關問題