2015-10-09 2 views
1

Я новичок в разработке Android (извините за мой английский и французский). У меня есть приложение со списком. Для списка у меня есть пользовательская строка.Относительная позиция расположения

Я хочу иметь этот результат:

Вот мой код:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:minHeight="60dp" 
    android:gravity="end" > 

    <TextView 
    android:id="@+id/messageID" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:visibility="gone"/> 

    <TextView 
    android:id="@+id/messageContactID" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:visibility="visible"/> 

    <TextView 
    android:id="@+id/messageContact" 
    android:layout_width="60dp" 
    android:layout_height="match_parent" 
    android:background="@color/previewContact" 
    android:gravity="center" 
    android:textColor="@color/white" 
    /> 

    <TextView 
    android:id="@+id/messageText" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:gravity="center_vertical" 
    android:paddingLeft="20dp" 
    android:paddingRight="20dp" 
    android:layout_toLeftOf="@id/messageContact" 
    android:background="@color/home_bg" 
    /> 
</RelativeLayout> 

Не могли бы вы мне помочь?

Ps я не могу использовать линейный макет

+0

в изображении я вижу только MessageText и messageContact, как насчет двух других TextView-х? как вы хотите их разместить? – Rami

+0

Можете ли вы уточнить, что именно вы хотите сделать? –

+0

Отображаются два других текста arent arent. они здесь для курсора apadter (адаптер курсора требуется _id) – Ananta

ответ

0

Попробуйте это:

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

    <TextView 
     android:id="@+id/messageID" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:visibility="gone"/> 

    <TextView 
     android:id="@+id/messageContactID" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:visibility="visible"/> 

    <TextView 
     android:id="@+id/messageContact" 
     android:layout_width="60dp" 
     android:layout_height="match_parent" 
     android:gravity="center" 
     android:background="@color/previewContact" 
     android:textColor="@color/white" 
     android:layout_alignParentRight="true" /> 

    <TextView 
     android:id="@+id/messageText" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="center_vertical" 
     android:paddingLeft="20dp" 
     android:paddingRight="20dp" 
     android:layout_alignParentLeft="true" 
     android:background="@color/home_bg" 
     android:layout_toLeftOf="@+id/messageContact" /> 
</RelativeLayout> 
+1

Спасибо! Оно работает :) – Ananta

Смежные вопросы