本文介绍了Android 可绘制语音气泡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经找了好几天了,但找不到任何关于如何绘制气泡或绘制 9 个补丁图像作为背景的好的线索.我是一个糟糕的艺术家 -- 谁能帮忙?
I've looked for days and can not find any good leads on how I can draw a bubble or where a draw 9 patch images is to use as a background. i am a terrible artist --Can anyone help?
我在stackoverflow上找到的最好的示例,但它是用objective c编写的
the best sample i found is here on stackoverflow, but it's written in objective c
谢谢
推荐答案
如果您正在创建聊天屏幕,您可能想要实现传入的对话气泡和传出的对话气泡.我是这样做的:
If you are creating a chat screen you are probably going to want to implement an incoming speech bubble and an outgoing speech bubble. Here is how I did that :
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:fromDegrees="-45"
android:pivotX="0%"
android:pivotY="0%"
android:toDegrees="0" >
<shape android:shape="rectangle" >
<solid android:color="@color/primary" />
</shape>
</rotate>
</item>
<item android:left="16dp">
<shape android:shape="rectangle" >
<solid android:color="@color/primary" />
<corners android:radius="4dp" />
</shape>
</item>
</layer-list>
shape_bg_outgoing_bubble.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:fromDegrees="45"
android:pivotX="100%"
android:pivotY="0%"
android:toDegrees="0" >
<shape android:shape="rectangle" >
<solid android:color="@color/grey_500" />
</shape>
</rotate>
</item>
<item android:right="16dp">
<shape android:shape="rectangle" >
<solid android:color="@color/grey_500" />
<corners android:radius="4dp" />
</shape>
</item>
</layer-list>
这篇关于Android 可绘制语音气泡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!