0

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. enter image description here

  • 1
    Using [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
  • 1
    why 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 Answers1

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

enter image description here