2014-02-12 37 views
0
插入ImageView的

我有下面的代码,告诉我有名字,成绩,性别,年龄和国家的一个ListItem:内部列表项

<?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" 
android:padding="10dip" > 


<RelativeLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

    <TextView 
     android:id="@+id/text_user" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:textSize="16sp" 
     android:textStyle="bold" /> 

    <RatingBar 
     android:id="@+id/ratingBar" 
     style="?android:attr/ratingBarStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_marginTop="5dp" 
     android:numStars="5" 
     android:rating="2.0" /> 
</RelativeLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="5dp" 
    android:gravity="left" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/text_last_message" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="12sp" /> 

    <TextView 
     android:id="@+id/text_status" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="12sp" /> 

    <TextView 
     android:id="@+id/text_country" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="12sp" /> 
</LinearLayout> 

而这种代码如下所示: enter image description here

我现在想要做的是添加图像配置文件,并显示如下列表项:

enter image description here

如何修改我的代码以适应imageview。我尝试了几次ImageView的配置,但没有成功。

感谢

回答

1
<?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" 
android:orientation="vertical" 
android:padding="10dip" > 

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 

<RelativeLayout 
    android:id="@+id/relativeLayout1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toRightOf="@+id/imageView1" > 

    <TextView 
     android:id="@+id/text_user" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:textSize="16sp" 
     android:textStyle="bold" /> 

    <RatingBar 
     android:id="@+id/ratingBar" 
     style="?android:attr/ratingBarStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_marginTop="5dp" 
     android:numStars="5" 
     android:rating="2.0" /> 
</RelativeLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/relativeLayout1" 
    android:layout_marginLeft="5dp" 
    android:layout_toRightOf="@+id/imageView1" 
    android:gravity="left" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/text_last_message" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="12sp" /> 

    <TextView 
     android:id="@+id/text_status" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="12sp" /> 

    <TextView 
     android:id="@+id/text_country" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="12sp" /> 
</LinearLayout> 

</RelativeLayout> 

试试这个..