Java 如何使此消息气泡位于右侧?
我将此作为我的listview中项目的布局:Java 如何使此消息气泡位于右侧?,java,android,listview,Java,Android,Listview,我将此作为我的listview中项目的布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/msgbox_self_default" > <RelativeLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/msgbox_self_default" >
<RelativeLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingLeft="7dip" >
<ImageView android:id="@+id/pending" android:layout_height="fill_parent"
android:layout_width="wrap_content" android:layout_marginLeft="2dip"
android:src="@drawable/ic_sms_mms_pending"
android:visibility="gone"
/>
<TextView
android:id="@+id/body"
android:text="@+id/body"
android:singleLine="false"
android:paddingLeft="@dimen/message_item_text_padding_left_right"
android:paddingRight="@dimen/message_item_text_padding_left_right"
android:paddingTop="@dimen/message_item_text_padding_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:linksClickable="false"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#ff000000"
android:textSize="16sp"
android:layout_alignParentRight="true" />
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="@id/body"
android:id="@+id/picture_layout"
android:orientation="vertical"
>
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/picture"
android:visibility="gone"
android:maxWidth="178dip" android:maxHeight="178dip"
android:layout_alignParentRight="true"
android:adjustViewBounds="true" android:background="@android:drawable/picture_frame"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
<TextView
android:paddingRight="@dimen/message_item_text_padding_left_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/picture_layout"
android:paddingLeft="3dip"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/date"
android:text="@+id/date"
android:singleLine="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
我希望泡沫在右边。这是一个消息气泡的布局。我试着把它放在右边,就像iPhone对话一样。我已经尝试了所有我能想到的关于把它放在右边而不是左边的事情。有人看到我的布局有什么问题吗?请帮忙!谢谢
**编辑**
绿色的泡泡是我在这张照片中的目标
*更改布局*
到目前为止,这就是我所拥有的。。还有什么想法吗
我希望灰色的气泡看起来像白色的气泡,除了右边。我不打算筛选你的代码,但基本上你只希望每条消息都像这样
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="put the right amount of padding in">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="make this your background, make sure to add padding in so that the text view is in the right place, look at 9 patches"
android:layout_alignParentRight="true"/><!-- Or make this left -->
</RelativeLayout>
不要让事情过于复杂,只要使用一个带有9补丁的文本视图,它就会做你想做的事情
只需水平交换9个补丁,它就会以另一种方式出现如下。。绿色泡泡是我想要完成的。他想在安卓里迪上有iPhone的对话风格。我只想在右边有信息泡泡。在顶部提供的布局中,气泡仅停留在左侧。我的另一个布局,我有气泡停留在右边,就像它应该。我需要的布局,因为我正在阅读彩信和短信在同一时间。当信息不是彩信时,我会隐藏图片视图,然后使用该相对布局中的文本发送短信。根据你的想法,我将无法合并图片。在它们周围放置一个线性布局,并将线性布局的背景设置为“九块”,而不是文本视图。谢谢你的建议。看看我的编辑。你还有别的想法吗?我贴了一张关于我得到了什么的图片。哇,这看起来很不错,你应该有它,这样相对版面内的线性版面与相对版面的左侧对齐,并确保线性版面的宽度包裹了内容。