简体   繁体   English

在 android 的聊天应用程序中创建文本气泡的更好选择?

[英]Better option to create text bubble in chat app in android?

I have this style I want to implement in my chat app when user sends a message:当用户发送消息时,我想在我的聊天应用程序中实现这种风格:

在此处输入图像描述

Should I use 9 patch or make it with XML ?我应该使用9 patch还是使用XML If XML is the better option how could I achieve this?如果XML是更好的选择,我怎么能做到这一点?

You can make an XML for this, and you should make a bubble for incoming and outgoing messages.您可以为此制作 XML,并且应该为传入和传出消息制作气泡。

This is one example for incoming chat bubble source .这是传入聊天气泡的一个示例。

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<!--Shadow Layers-->

<item>
    <rotate
        android:fromDegrees="-35"
        android:pivotX="0%"
        android:pivotY="0%"
        android:toDegrees="0">
        <shape android:shape="rectangle">
            <corners android:radius="4dp"/>
            <padding
                android:bottom="1px"
                android:left="1px"
                android:right="1px"/>
            <solid android:color="#01000000" />
        </shape>
    </rotate>
</item>
<item android:left="8dp">
    <shape android:shape="rectangle">
        <padding
            android:bottom="1px"
            android:left="1px"
            android:right="1px"/>
        <solid android:color="#01000000" />
        <corners android:radius="8dp" />
    </shape>
</item>

<!--===============-->
<item>
    <rotate
        android:fromDegrees="-35"
        android:pivotX="0%"
        android:pivotY="0%"
        android:toDegrees="0">
        <shape android:shape="rectangle">
            <corners android:radius="4dp"/>
            <padding
                android:bottom="1px" />
            <solid android:color="#09000000" />
        </shape>
    </rotate>
</item>
<item android:left="8dp">
    <shape android:shape="rectangle">
        <padding
            android:bottom="1px" />
        <solid android:color="#09000000" />
        <corners android:radius="8dp" />
    </shape>
</item>

<!--===============-->

<item>
    <rotate
        android:fromDegrees="-35"
        android:pivotX="0%"
        android:pivotY="0%"
        android:toDegrees="0">
        <shape android:shape="rectangle">
            <corners android:radius="4dp"/>
            <padding
                android:bottom="1px"
                android:left="1px"
                android:right="1px"/>
            <solid android:color="#10000000" />
        </shape>
    </rotate>
</item>
<item android:left="8dp">
    <shape android:shape="rectangle">
        <padding
            android:bottom="1px"
            android:left="1px"
            android:right="1px"/>
        <solid android:color="#10000000" />
        <corners android:radius="8dp" />
    </shape>
</item>

<!--ForeGround-->

<item>
    <rotate
        android:fromDegrees="-35"
        android:pivotX="0%"
        android:pivotY="0%"
        android:toDegrees="0">
        <shape android:shape="rectangle">
            <corners android:radius="4dp"/>
            <solid android:color="@color/colorWhite" />
        </shape>
    </rotate>
</item>
<item android:left="8dp">
    <shape android:shape="rectangle">
        <solid android:color="@color/colorWhite" />
        <corners android:radius="8dp" />
    </shape>
</item>

</layer-list>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 聊天应用程序 - 哪种技术更适合在Android中实现聊天应用程序 - Chat application - which tech is better to implement chat app in Android 哪种气泡聊天更适合用作性能9补丁图像或RelativeLayout? - Which is better to use for bubble chat as performance 9-patch image or RelativeLayout? AWS Android聊天应用程序 - AWS Android Chat App 第一条用户消息后,Android 气泡聊天的不同布局 - Android bubble chat different layout after first user message 在Android Studio中使用用户输入进行气泡排序应用 - bubble sort app with user input in android studio Android Studio 中的 Firebase 聊天应用 - Firebase chat app in android studio 创建一个从url读取文本的android应用 - create an android app that reads text from url 如何在聊天适配器中标记特定的聊天气泡 - How to mark specific chat bubble in Chat Adapter 使用 Selenium 自动化聊天机器人时如何从最新的聊天气泡中获取文本 - How to get the text from the latest chat bubble when automating chatbot using Selenium PhoneGap或Android会更适合此应用程序创意吗? - Will PhoneGap or Android be better for this app idea?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM