Using parents for drawable resources

a 夏天 提交于 2019-12-22 03:51:21

问题


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?


回答1:


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.


来源:https://stackoverflow.com/questions/12758768/using-parents-for-drawable-resources

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!