0

I understand how to create gradients using start color, end color, etc like below:-

<?xml version="1.0" encoding="utf-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
  <gradient
      android:type="radial" android:gradientRadius="260"
      android:startColor="#A74171" android:endColor="#690136"/>
 </shape>

But I dont understand how to bring about more complex effects. For Eg:- I am faced with a task of making a textview look like a button where it will look a little raised at the center, something like the image attached . How can such an effect be brought by code without using images?

Rasmus
  • 8,248
  • 12
  • 48
  • 72

1 Answers1

0

Here's the good news: Something like the button, shown in the picture, already exists. Maybe in other colors, but with a little painting you should get there easily. Check out the design downloads

  • When there're good news, than there might be some news with - lets say - more work involved. This link to Drawable Resource gives you an overview of what is possible with XML.

  • When you get out of XML possibilities, you must create your own Drawable, which is described here which is extremely powerful.

  • You can always paint your own drawings, load them as bitmap and use them. There you must be very sensitive on the size of the bitmap and the good looking (painted with enough pixels). I mysef have not found the right mix up to now.

All in all, in my experience, even the most complex XML drawables are quite efficient, whereas my own Drawables, painted at runtime are always a cause for lagging on the UI-Thread.

jboi
  • 11,324
  • 4
  • 36
  • 43