Custom ImageView shape drawable in xml like this one

740 views Asked by At

I want to create an ImageView like this one. I know it's a combination of a rectangle and a triangle shape, but I really don't know how to implement it.

enter image description here

Is it possible in XML?. Does layer-list seem to help in this case?. I would like to have some example drawable xml codes. [The example Image belongs to someone from Dribbble.]

1

There are 1 answers

6
A.S On

Is it possible in XML?

yes, I think you can achieve this by manipulating corner tag attributes

(for example):

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#FFFFFF"/>
<corners 
android:bottomRightRadius="0dp"
android:topLeftRadius="15dp"
/>
</shape>

here we specified bottomRightRadius to be 0 and topLeftRadius to be 15 which will effect one corner and that would results irregular shape similar to the one that you have requested. try to play around with those attributes to achieve what you are asking for.

hope this will help.