How to create this custom shape in android ?
My requirement is, i want to create a CardView with above shape. Inside this cardview, there will be other textviews and imageviews present. Under the top curve of the card, i need to place a small icon.
Can this shape be created in UI design tools like figma ?
If it is possible in Figma, then we can take the XML generated in figma and use it in android code.
Asked
Active
Viewed 149 times
0

K Pradeep Kumar Reddy
- 632
- 8
- 16
-
1Using [Path](https://developer.android.com/reference/android/graphics/Path) is one way. – Darkman May 10 '21 at 07:26
-
@Darkman Can i create this as a drawable and set it as background for CardView ? – K Pradeep Kumar Reddy May 10 '21 at 07:55
-
1why not use a image? – Matrix May 10 '21 at 08:03
-
1@KPradeepKumarReddy Yes, of course. Draw it on a custom `Canvas` then use the `Bitmap` for the background. Or like the above commenter said, you can just use an image. – Darkman May 10 '21 at 08:30
-
@Darkman Can you please elaborate your answer ? I'm not able to understand how i can use an image ? My requirement is, i want to create a CardView with above shape. Inside this cardview, there will be other textviews and imageviews present. Just below the top curve of the card, a small icon will be there. – K Pradeep Kumar Reddy May 10 '21 at 11:15
-
@Anna Can you please elaborate your answer ? I'm not able to understand how i can use an image ? My requirement is, i want to create a CardView with above shape. Inside this cardview, there will be other textviews and imageviews present. Under the top curve of the card, i need to place a small icon. – K Pradeep Kumar Reddy May 10 '21 at 11:23
1 Answers
0
create xml file in drawable folder with Root Element "layer-list" and copy this code inside of "layer-list" tag :) , add the code to the cardview background
Unfortunately, I could not add the code in the comment Please see the photo

Afsaneh Fallahzadeh
- 11
- 2