我正在尝试为我正在开发的android应用程序中的聊天气泡创建一个模板。最终结果应该如下所示:

我尝试了它的形状,但我不能得到正确的多层。我也尝试了9补丁映像,但创建9补丁是我目前所能做到的。我不知道如何使用它,特别是头像,消息头和内容放置。
有人能帮上忙吗?
我对形状的知识相当有限,尽管,我想我所知道的足以理解你们将要说的话:)
发布于 2015-02-14 17:23:15
9补丁真的很简单。这里有一个很好的教程:Simple Guide to 9 Patch。
只需将扩展名设为.9.png,而不仅仅是.png。
将其用作ViewGroup (视图容器)的背景,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/row"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bubble_left"
android:layout_margin="8dp"
android:padding="8dp"
>
<!-- The User -->
<TextView
android:id="@+id/txtUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
/>
<!-- The Date -->
<TextView
android:id="@+id/txtDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/txtUser"
/>
<!-- The Message -->
<TextView
android:id="@+id/txt2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/txtDate"
/>
</RelativeLayout>我让你自由选择你想要的图形(符合你的口味,不会破坏你的乐趣)。
显然,您可能希望为左侧准备一个气泡,为右侧准备一个气泡(或者让气泡具有不同颜色的边角),并在Java代码中相应地交换它们。
https://stackoverflow.com/questions/28506117
复制相似问题