如何添加气泡TextView的Android的? [英] How to add the bubbles to textview android?
问题描述
我在我的应用我去设置气泡文本视图,在文本视图中我添加了setBackgroundResource如见code
I my application i went to set the bubbles to text view ,in text view i add the setBackgroundResource as see in code
在此code我越来越喜欢这个形象
in this code i'm getting like this image
我去喜欢这个泡沫形状的图像
i went bubble shape image like this
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#EDF5E4" />
<corners android:bottomLeftRadius="@dimen/corner_radius"
android:bottomRightRadius="@dimen/corner_radius"
android:topLeftRadius="@dimen/corner_radius"
id:topRightRadius="@dimen/corner_radius" />
请告诉如何使这个在我setBackgroundResource XML
pls tell how to make this in my setBackgroundResource Xml
推荐答案
您需要使用什么本质上是一个9片图像(前面已经指出肯·沃尔夫在此评论的)。
What you need to use is essentially a 9-patch image (As already pointed out by Ken Wolf in this comment).
要你开始,我是其中的一组9片图像从我的应用程序之一以及一个简单的一块code。关于如何创建一个布局XML时使用它。 ; - )
To get you started, I am including a set of 9-patch images from one of my apps along with a brief piece of code on how to use it when creating a layout XMl. ;-)
的9个补丁图片集:
(这些被命名为: bubble_white_normal_mdpi.9
, bubble_white_normal_hdpi.9
和 bubble_white_normal_xhdpi。 9
分别。删除在 _mdpi _hdpi 和 _xhdpi 从文件名后将它们放置在各自的绘制
文件夹。
(These are named: bubble_white_normal_mdpi.9
, bubble_white_normal_hdpi.9
and bubble_white_normal_xhdpi.9
respectively. Remove the _mdpi, _hdpi and _xhdpi from the file names after placing them in their respective drawable
folders.
的XML:
<LinearLayout
android:id="@+id/linlaUserOther"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="2dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="top|center" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="@+id/imgvwProfileOther"
android:layout_width="42dp"
android:layout_height="42dp"
android:adjustViewBounds="true"
android:contentDescription="@string/content_desc_user_profile"
android:scaleType="centerCrop"
android:src="@drawable/ic_contact_picture" >
</ImageView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/bubble_white_normal"
android:gravity="top|center"
android:orientation="vertical" >
.... // OTHER STUFF HERE THAT IS NOT NECESSARY IN THIS CODE SNIPPET ON SO
</LinearLayout>
</LinearLayout>
注1:
虽然,我是其中一个工作组图像(几乎勺子喂养,如果你愿意的),我会强烈建议你创建自己的一套适合你的东西方案图像。此外,这也将装备你建立你自己的资源在未来。我继续走下去的唯一理由的加倍努力的是因为我个人失去了3天获得语音泡沫的前瞻性和工作的权利。 : - (
Although, I am including a working set of Images (almost spoon feeding, if you will), I would strongly urge you to create your own set of images that fit in your scheme of things. Plus, this will also equip you to build your own resources in the future. The only reason I am going the extra mile is because I personally lost 3 days getting the speech bubble looking and working right. :-(
注2:
我设置的图片作为背景,以一个的LinearLayout
。然而,你需要将其设置为的TextView
你需要看起来像一个语音气泡。
I am setting the image as a background to a LinearLayout
. You, however, will need to set it to the TextView
you need looking like a Speech Bubble.
其他网站(教程):
- http://adilsoomro.blogspot.in/
- <一个href="https://github.com/AdilSoomro/Android-Speech-Bubble">https://github.com/AdilSoomro/Android-Speech-Bubble
- <一个href="http://developer.android.com/reference/android/graphics/NinePatch.html">http://developer.android.com/reference/android/graphics/NinePatch.html
- <一个href="http://developer.android.com/tools/help/draw9patch.html">http://developer.android.com/tools/help/draw9patch.html
- http://adilsoomro.blogspot.in/
- https://github.com/AdilSoomro/Android-Speech-Bubble
- http://developer.android.com/reference/android/graphics/NinePatch.html
- http://developer.android.com/tools/help/draw9patch.html
这篇关于如何添加气泡TextView的Android的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!