메시지가 왼쪽과 오른쪽으로 표시되는 목록보기를 사용하여 채팅과 같은보기를 만들려고합니다. 왼쪽 메시지의 마크 업리스트 레이아웃과 같은 Android 레이아웃 채팅
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="left">
<TextView
android:id="@+id/MessageListItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:background="@drawable/RoundedCornersBlue"
android:padding="8dp"
android:text="realy long realy long realy long realy long realy long realy long realy long realy long "
android:layout_marginRight="5dp" />
<TextView
android:id="@+id/MessageListItemDate"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#cbc4b1"
android:text="23:11"
android:gravity="center_horizontal|center_vertical" />
</LinearLayout>
이지만 제 텍스트 뷰 (타임 스탬프)를 누락한다.
http://i.stack.imgur.com/JxDXQ.jpg
오른쪽 메시지가 나도 그것을 원하는이 하나가 보인다
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="right">
<TextView
android:id="@+id/MessageListItemDate"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#cbc4b1"
android:text="12:34"
android:gravity="center_horizontal|center_vertical" />
<TextView
android:id="@+id/MessageListItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="realy long realy long realy long realy long realy long realy long realy long realy long "
android:background="@drawable/RoundedCornersBlue"
android:padding="8dp"
android:layout_marginLeft="5dp" />
</LinearLayout>
http://i.stack.imgur.com/1MnyW.jpg
다음과 같은 마크 업을 가지고있다. 왼쪽과 오른쪽의 유일한 차이점은 LinearLayout의 android : gravity와 LinearLayout의 textviews 순서입니다.
내가 뭘 잘못하고 있는지 아는 사람이 있습니까? 아니면 내가 디자인
의이 유형을 달성 할 수있는 방법 당신은 채팅의 두 개의 서로 다른 XML을 만들 필요가 없습니다, 미하이
(질문과 관련이 없지만 여전히) 레이아웃이 수평이므로 선형 레이아웃의 중력은 무시됩니다. 수직 관련 중력 만이 사용될 수있다. (그리고 그 반대, 수직 방향에 대한 수평 중력) – njzk2