0

I want to use round Button in my app and add shadow behind it/around the corner. You can create that shadow if your Button is circular by adding gradient and setting it to radial will create round shadow around the button (because solid color is covered by real Button background). But if you want to use round button, but with rectangular shape, gradient is still circular and I cannot use it. Is there any way how to create rectangular gradient with same effect?

Another hack how to create shadow is by using 9patch shadow generator, but it is working only with certain dpi. (If you generate .png shadow for 200x100dp Button, it will cover corners exactly only for 200x100dp Button and its not generic solution)

<gradient
    android:endColor="@android:color/transparent"
    android:centerColor="@color/grey"
    android:startColor="@color/grey"
    android:gradientRadius="200dp"
    android:type="radial" />
Kaushik Burkule
  • 816
  • 1
  • 12
  • 27
martin1337
  • 2,384
  • 6
  • 38
  • 85

0 Answers0