这是工作的可绘制对象custom_shape_chat_box.xml
:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Transparent Rectangle -->
<item>
<shape android:shape="rectangle">
<size
android:width="300dp"
android:height="60dp" />
<solid android:color="@android:color/transparent" />
</shape>
</item>
<!-- Colored Rectangle -->
<item
android:right="20dp">
<shape android:shape="rectangle">
<size
android:width="300dp"
android:height="60dp" />
<solid android:color="#5EB888" />
</shape>
</item>
<!-- Bottom-Right Triangle -->
<item
android:left="20dp"
android:right="0dp"
android:top="-10dp"
android:bottom="20dp">
<rotate android:fromDegrees="26">
<shape android:shape="rectangle">
<solid android:color="#5EB888" />
</shape>
</rotate>
</item>
</layer-list>
利用:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="24dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/custom_shape_chat_box">
</LinearLayout>
</LinearLayout>
输出:
希望这会有所帮助~