2013-12-16 99 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"

相关问题