Mr T
Mr T

Reputation: 1499

android custom shape as background drawable

I am trying to draw the blue shape below. I want my dialog to have this custom blue shape. But I can not figure out. I have tried the below code.

I really appreciate your tips, Thanks

<item>
    <rotate
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="0">
        <shape android:shape="rectangle">
            <solid android:color="@color/red_color" />
        </shape>
    </rotate>

</item>

<item>
    <rotate
        android:fromDegrees="-10"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="-10">
        <shape android:shape="rectangle">
            <solid android:color="@color/gray_color" />
        </shape>
    </rotate>
</item>

enter image description here

To show the inclination enter image description here

This is the result from my code above: enter image description here

Upvotes: 0

Views: 1144

Answers (1)

Raghavan R
Raghavan R

Reputation: 66

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

<item android:top="87dp"
    android:bottom="-300dp"
    android:left="0dp"
    android:right="-300dp">
    <rotate
        android:fromDegrees="-10"
        android:pivotX="0%"
        android:pivotY="100%">
        <shape
            android:shape="rectangle">
            <solid
                android:color="@android:color/holo_blue_light"/>
        </shape>
    </rotate>
</item>

Using the above code you will achieve the inclination. Note: change the color code as you need. Upvote the code if you find it useful.

Upvotes: 1

Related Questions