在Android中创建聊天泡泡

在Android中创建聊天泡泡,android,android-layout,android-widget,Android,Android Layout,Android Widget,我试图用一些文字创建一个聊天泡泡。为此,我创建了三个布局,在主线性布局的内部,我使用FramLayout,我正在为此Framlayout设置一个9补丁背景。在Framlayout内部,我正在添加另一个RelativeLayout,在其中放置我的三个文本视图和一个图像视图。但键入长文本会超出Framlayout边框。我不知道我做错了什么或缺少了什么。当我使用小文本时,它仍然适合,但对于大文本,它会消失从FramLayout的背景边界。在附件中,我展示了我的泡泡和yahoo IM泡泡。我试图创建与y

我试图用一些文字创建一个聊天泡泡。为此,我创建了三个布局,在主线性布局的内部,我使用FramLayout,我正在为此Framlayout设置一个9补丁背景。在Framlayout内部,我正在添加另一个RelativeLayout,在其中放置我的三个文本视图和一个图像视图。但键入长文本会超出Framlayout边框。我不知道我做错了什么或缺少了什么。当我使用小文本时,它仍然适合,但对于大文本,它会消失从FramLayout的背景边界。在附件中,我展示了我的泡泡和yahoo IM泡泡。我试图创建与yahoo相同但风格不同的泡泡。请给我你的建议。我用不同的方式尝试了很多,但没有成功。提前感谢。 我在这里放置我的布局文件

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

       <FrameLayout
           android:id="@+id/frameLayout1"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           android:background="@drawable/bubbleblue" >

            <RelativeLayout
              android:id="@+id/relativeLayout1"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent" 
              android:minHeight="100dp">

                <TextView
                    android:id="@+id/chattitle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="TextView"
                    android:layout_marginTop="10dp"
                    android:layout_marginLeft="10dp"/>

               <TextView android:id="@+id/chatdate"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="TextView"
                    android:layout_alignParentRight="true"
                    android:layout_marginTop="10dp"/>

               <TextView android:id="@+id/chatText"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:layout_alignBottom="@+id/chatstatus"
                   android:layout_below="@+id/chattitle"
                   android:layout_toLeftOf="@+id/chatstatus"
                   android:text="TextView" />

              <ImageView
                  android:id="@+id/chatstatus"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:src="@drawable/add_picture"
                  android:layout_alignParentRight="true"
                  android:layout_below="@+id/chatdate"
                  android:minHeight="2dip"
                  android:maxWidth="2sp"
                  android:maxHeight="2sp"
                  android:layout_marginRight="2dp"/>
        </RelativeLayout>
  </FrameLayout>


创建.9patch图像时,还必须指定一个内容区域,该区域由左侧和底部像素定义

使用 及

用于根布局项的背景


右键单击图像并选择将目标另存为

我们需要查看布局文件。对于这类事情,我偏爱线性/相对论。FrameLayouts在我看来可能有点毛茸茸的。你有没有尝试过填充?是的,我也尝试过填充,还使用了边距。我写了一篇关于的博客文章,你也可以在那里找到开源代码。看看这个项目:嗨,对于9-patch,我做的事情和你链接上给出的一样。@user717572页面未找到。