简体   繁体   English

Android Gradient可绘制颜色变化

[英]Android Gradient drawable color change

I have a shape drawable in the drawable folder. 我在drawable文件夹中有一个可绘制的形状。 Here is XML structure: 这是XML结构:

<?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. 现在我想从运行时的java代码中更改startColor,centerColor,endColor。 How it is possible to change? 如何改变?

Unfortunately there's no API to do this. 不幸的是,没有API可以做到这一点。 I'll add one to a future Android release. 我将在未来的Android版本中添加一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM