2012-02-22 47 views
9

我正在尝试创建一些文本的聊天泡泡。为此,我创建了三个Layoutouts,主线性布局内部我使用FramLayout,我设置了9个补丁背景对于此Framlayout在Framlayout的内部,我添加了一个RelativeLayout,在这里我放置了三个textView和一个imageView.but输入了长文本,它超出了FramLayout边界。我不知道我做错了什么或者我什么都没有。当我我使用小文本它仍然适合,但与大文本,它甚至从FramLayout的背景边框出去。附件我正在显示我的泡沫和雅虎即时消息泡泡。我试图创建像雅虎一样但有一些不同style.Please给我你的建议。我尝试了很多不同的方式,但没有成功。提前感谢。 。 enter image description here 在这里,我把我Layoutfile在Android中创建一个聊天泡泡

 <?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> 

+0

那么我们需要看到布局文件。我对这种事情偏爱Linear/RelativeLayouts。 FrameLayouts可以得到一个多毛的国际海事组织。 – Phix 2012-02-22 17:15:42

+0

你是否尝试过填充? – jmcdale 2012-02-22 17:18:03

+0

是的,我也使用填充,并使用余量。 – aftab 2012-02-22 17:23:55

回答

4

在创建.9patch形象,还必须指定一个内容区域,你用左手定义,和底部的像素。 Check out this.

+0

嗨9 - 补丁我做同样的事情,因为它给你的链接上.http://developer.android.com /guide/developing/tools/draw9patch.html – aftab 2012-02-22 17:23:11

+0

@ user717572找不到页面。 – 2018-02-21 07:54:50

0

使用 enter image description hereenter image description here

为根布局项目的背景。

右键点击图片并选择将目标另存为

+0

尽管这个链接可能回答这个问题,但最好在这里包含答案的基本部分,并提供供参考的链接。如果链接页面更改,则仅链接答案可能会失效。 - [来自评论](/ review/low-quality-posts/16876375) – MikeT 2017-07-31 00:35:26