2

I would like to be able to define a gradient drawable and then reference this gradient in other shape drawables. Is something along these lines possible, or do I have to specifiy the gradient in every shape resource over again?

in file my_gradient.xml

<gradient
    android:angle="180"
    android:endColor="@color/Gradient2Light"
    android:startColor="@color/Gradient2Dark" >
</gradient>

and then just have

<shape xmlns:android="http://schemas.android.com/apk/res/android" >

<gradient id="@drawable/my_gradient" />

<stroke
    android:width="1dp"
    android:color="#2f6699" />

<corners android:radius="3dp" />

Is something like this possible and if yes, then how?

David Miler
  • 100
  • 2
  • 14
  • 2
    I am not aware that this is possible. I suppose you could see if `` tags work, like they do in layout resources, but AFAIK `` is a layout-only thing. Beyond that, stick `180` in an integer resource, and at least your values will be centrally defined, even if the `` element itself will not. – CommonsWare Nov 22 '12 at 12:46
  • You could try the [include tag](http://stackoverflow.com/questions/6306791/android-include-a-xml-into-an-other-xml) like described here: – Aeefire Nov 22 '12 at 12:46

0 Answers0