在 Android 中创建聊天气泡

编程入门 行业动态 更新时间:2024-10-15 14:20:00
本文介绍了在 Android 中创建聊天气泡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试创建一个带有一些文本的聊天气泡.为此,我创建了三个布局,在主要线性布局内部我正在使用 FramLayout,我正在为此 Framlayout 设置一个 9 补丁背景.在 Framlayout 内部我是在我放置三个 textView 和一个 imageView 的地方再添加一个 RelativeLayout.但是输入长文本它会超出 FramLayout 边框.我不知道我做错了什么或我错过了什么.当我使用小文本时,它仍然存在适合但带有大文本,它甚至从 FramLayout 的背景边框中消失.在附件中,我正在展示我的气泡和雅虎 IM 气泡.我正在尝试创建与雅虎相同但具有一些不同风格的内容.请给我您的建议.我尝试很多不同的方法,但没有成功.提前致谢..我在这里放置我的布局文件

I am trying to create a chat bubble with some text.For this I am create Three Layoutouts,Inside of main Linear Layout I am using FramLayout,I am setting a 9-patch background To this Framlayout.Inside of Framlayout I am adding one more RelativeLayout where I am placing my three textViews and one imageView.but type long text it goes outside of FramLayout border.I don't know what I am doing wrong or what I am missing.When I am using small text it remain fit but with big text it goes out from even Background Border of FramLayout.In attachment I am showing my bubble and yahoo IM bubble.I am trying to create same like yahoo but with some different style.Please give me your suggestion.I try a lot with different ways but not get success.Thanks in advance . . Here I am placing my Layoutfile

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="schemas.android/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 图像时,您还必须指定一个内容区域,您可以使用左侧和底部像素定义该区域.看看这个.

When creating your .9patch image, you also must specify a content area, which you define with the left, and bottom pixels. Check out this.

更多推荐

在 Android 中创建聊天气泡

本文发布于:2023-11-04 18:17:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1558668.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:气泡   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!