本文介绍了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上,但它是用客观的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
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可绘制的演讲泡沫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!