Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using parents for drawable resources

When I define a style, it can be inherited from a parent style, e.g:

<style name="DialogNoTitle" parent="@android:style/Theme.Dialog">
    <item name="android:windowNoTitle">true</item>
</style>

Now I want to do the same with drawable resources, something like this:

<shape xmlns:android="http://schemas.android.com/apk/res/android" name="ChildDrawable" parent="@drawable/ParentDrawable">
    <solid android:color="@android:color/white"/>
    <corners android:radius="6dp"/>
</shape>

Is there a way to accomplish this functionality?

like image 481
user940016 Avatar asked Oct 06 '12 10:10

user940016


1 Answers

Short answer - you cannot extend and override drawables. However,

  • Some drawables can be created from other drawables. e.g. layer-list will allow you to draw layers of drawables one on top of another. Refer to http://developer.android.com/guide/topics/resources/drawable-resource.html .
  • You create Drawable objects in code.
like image 79
Sameer Avatar answered Oct 03 '22 23:10

Sameer