Android: implements multiple segments as gradient color
This commit is contained in:
parent
bcc66b51b9
commit
d91142a1db
@ -234,15 +234,22 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
|
|||||||
if (prop.isNumber()) {
|
if (prop.isNumber()) {
|
||||||
setBackgroundColor(prop.asNumber().toInt());
|
setBackgroundColor(prop.asNumber().toInt());
|
||||||
} else if (prop.isObject()) {
|
} else if (prop.isObject()) {
|
||||||
JSValue start = prop.asObject().getProperty("start");
|
|
||||||
JSValue end = prop.asObject().getProperty("end");
|
|
||||||
JSValue orientation = prop.asObject().getProperty("orientation");
|
|
||||||
|
|
||||||
GradientDrawable gradientDrawable = new GradientDrawable();
|
GradientDrawable gradientDrawable = new GradientDrawable();
|
||||||
gradientDrawable.setShape(GradientDrawable.RECTANGLE);
|
gradientDrawable.setShape(GradientDrawable.RECTANGLE);
|
||||||
gradientDrawable.setColors(new int[]{start.asNumber().toInt(), end.asNumber().toInt()});
|
|
||||||
gradientDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
|
gradientDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
|
||||||
|
|
||||||
|
if (prop.asObject().propertySet().contains("colors")) {
|
||||||
|
JSValue colors = prop.asObject().getProperty("colors");
|
||||||
|
|
||||||
|
gradientDrawable.setColors(colors.asArray().toIntArray());
|
||||||
|
} else {
|
||||||
|
JSValue start = prop.asObject().getProperty("start");
|
||||||
|
JSValue end = prop.asObject().getProperty("end");
|
||||||
|
|
||||||
|
gradientDrawable.setColors(new int[]{start.asNumber().toInt(), end.asNumber().toInt()});
|
||||||
|
}
|
||||||
|
JSValue orientation = prop.asObject().getProperty("orientation");
|
||||||
|
|
||||||
switch (orientation.asNumber().toInt()) {
|
switch (orientation.asNumber().toInt()) {
|
||||||
case 0:
|
case 0:
|
||||||
gradientDrawable.setOrientation(GradientDrawable.Orientation.TOP_BOTTOM);
|
gradientDrawable.setOrientation(GradientDrawable.Orientation.TOP_BOTTOM);
|
||||||
|
Reference in New Issue
Block a user