2010-11-20 9 views
1

Je veux mes articles de ligne pour ressembler à ceci: alt textComment faire pour que mon ListViewItem ressemble à l'application Twitter?

Je veux avoir une image sur la gauche, en haut et en bas du texte et une date. J'ai commencé à poser, mais je ne suis pas sûr de savoir comment procéder avec le reste du XML:

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

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:id="@+id/avatarImageView"> 
    </ImageView> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/usernameTextView" 
     android:text="username" 
     android:layout_toRightOf="@+id/avatarImageView" 
     android:layout_alignParentTop="true"> 
    </TextView> 

    <TextView 
     android:id="@+id/bodyTextView" 
     android:layout_below="@+id/usernameTextView" 
     android:layout_toRightOf="@+id/avatarImageView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="body"> 
    </TextView> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/usernameTextView" 
     android:id="@+id/dateTextView" 
     android:text="date"> 
    </TextView> 
</RelativeLayout> 

Répondre

3

Vous voulez vérifier RelativeLayout, est beaucoup plus facile pour les dispositions de ce genre, il serait quelque chose comme.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="?android:attr/listPreferredItemHeight" 
    android:padding="6dip"> 

<ImageView id="@+id/badge" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    .../> 

<TextView id="@+id/title" 
    android:layout_toRightOf="@id/badge" 
    android:layout_alignParentTop="true" 
    .... 
    /> 

<TextView id="@+id/body" 
    android:layout_below="@id/title" 
    android:layout_toRightOf="@id/badge" 
    .... 
    /> 
</RelativeLayout> 

Sinon, vous devez imbriquer LinearLayouts mixtes, par ex. un LinearLayout extérieur gauche à droite, puis un Lineaar Layout vertical imbriqué pour le corps du titre, etc

Questions connexes