Android Gradient drawable color change

☆樱花仙子☆ 提交于 2019-12-12 13:05:10

问题


I have a shape drawable in the drawable folder. Here is XML structure:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient 
        android:startColor="#4D0418" 
        android:centerColor="#5F031D"
        android:endColor="#7D0227" 
        android:angle="-90" />
</shape>  

Now I want to change the startColor, centerColor, endColor from the java code in the runtime. How it is possible to change?


回答1:


Unfortunately there's no API to do this. I'll add one to a future Android release.



来源:https://stackoverflow.com/questions/7925978/android-gradient-drawable-color-change

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