1

I'm looking for a simple solution to to draw a rectangle with one edge that is curved. I'm trying to avoid creating a custom rectangle class and manually drawing it as I believe there's a much simpler solution that I have not considered. I have attached an image of the design I wish to create. Thank you in advance enter image description here

edit: I was thinking it maybe easier to round the white rectangle but I'm open to rounding the purple one. enter image description here

VirtualProdigy
  • 1,637
  • 1
  • 20
  • 40

2 Answers2

2

If I understand the question, this existing answer on SO solves your problem - https://stackoverflow.com/a/9885817.

However, if that doesn't solve your problem, I believe that you can define an android:gradient and there are existing attributes that can curve sides.

Sorry I don't have a more detailed answer, I'm just waking up now lol

Community
  • 1
  • 1
Adam Ratzman
  • 143
  • 2
  • 8
2

You can try and play with oval shape and insets. Example:

<_inset xmlns:android="http://schemas.android.com/apk/res/android"
       android:insetBottom="-20dp"
       android:insetLeft="-20dp"
       android:insetRight="-20dp">

    <shape android:shape="oval">
        <solid android:color="#FF0000"/>
    </shape>

</inset>

I got a result similar to what you need with this

Alex Orlov
  • 18,077
  • 7
  • 55
  • 44