Search code examples
androidxmlandroid-layoutdrawable

Chat Bubble background Xml


I am trying create chat drawable background but not for chat just for view.Tried using some codes no able acheive fully as per the required. please help me to finish this.

Required image:

enter image description here

My code:

<?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="100%"
        android:toDegrees="0" >
        <shape android:shape="rectangle" >
            <solid android:color="@color/colorWhite" />
        </shape>
    </rotate>
</item>

<item android:left="20dp">
    <shape android:shape="rectangle" >
        <solid android:color="@color/colorWhite" />
        <corners android:radius="5dp" />
    </shape>
</item>

enter image description here


Solution

  • try this

    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    
        <item>
            <rotate
                android:fromDegrees="45"
                android:pivotX="0%"
                android:pivotY="10%"
                android:toDegrees="0">
                <shape android:shape="rectangle">
                    <solid android:color="@color/colorBlack" />
                </shape>
            </rotate>
        </item>
    
        <item
    
            android:top="50dp">
            <shape android:shape="rectangle">
                <solid android:color="@color/colorWhite" />
                <corners android:radius="5dp" />
            </shape>
        </item>
    </layer-list>