【发布时间】:2018-06-10 07:22:42
【问题描述】:
在构建Android应用项目时,有一个背景颜色预设文件,如:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:startColor="#ffffff"
android:centerColor="#00ffff"
android:endColor="#000000"
android:type="linear"
android:angle="90"/>
使用 android:startColor, android:centerColor, android:endColor, android:type, android:angle 的字符串值,我们如何以编程方式制作这个渐变?
【问题讨论】:
-
见
GradientDrawable -
有梯度绘制指南,但它们不基于字符串值
-
什么字符串值?你什么意思?你检查
GradientDrawable文档了吗? -
like "#000000"# not 0f-a0-c1..
-
那些不是字符串。它们是颜色。您可以使用颜色资源来存储它们。