2012-07-19 50 views
0

我有这个作为我的布局在我的列表视图中的项目:如何让这个消息泡泡在右侧?

<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对话这样的右侧。我已经尝试过所有我能想到的关于把它放在右侧而不是左侧的东西。有人看到我的布局有什么问题吗?请帮忙!由于

**编辑**

绿色的泡沫,我在这张照片瞄准的一个

http://getandroidstuff.com/wp-content/uploads/2010/12/GO-SMS-Android.jpg

*改变布局*

这是迄今为止我有什么想法?

Example

我想要灰色的泡沫看起来像白色的人,除了在右侧。

+0

你是什么意思的泡沫? – 0gravity 2012-07-19 23:55:05

+0

像这样http://getandroidstuff.com/wp-content/uploads/2010/12/GO-SMS-Android.jpg ..绿色泡泡就是我想要做到的 – 2012-07-19 23:56:19

+0

他希望iPhone上的对话风格在Android – FabianCook 2012-07-20 00:02:16

回答

0

我不是要通过你的代码中进行筛选,但基本上你只是想这样的事情每个消息

<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个补丁,它会围绕另一个方向

+0

我需要布局,因为我正在同时阅读彩信和短信。当消息不是MMS消息时,我隐藏图片视图,然后使用SMS的相对布局中的文本。有了你的想法,我也无法将图片也纳入其中。 – 2012-07-20 00:11:11

+0

在它们周围放置线性布局,并将线性布局的背景设置为九个补丁而不是文本视图。 – FabianCook 2012-07-20 00:16:24

+0

感谢您的建议。看看我的编辑。你还有什么想法?我张贴了一张关于我所得到的照片。 – 2012-07-20 00:26:11