A space-separated list of colors. You must specify each color using either the
ARGB format (#ff000000 = opaque black) or the RGB format (#000000 = black).
positions
A space-separated list of floats. The relative positions [0..1] of each
corresponding color in the colors attribute. If this is an empty string, the
colors are distributed evenly along the gradient line.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-05-20 UTC.
[null,null,["Last updated 2025-05-20 UTC."],[],[],null,["# LinearGradient\n\nWatch Face Format version Version 4 Version 3 Version 2 Version 1\n\n*** ** * ** ***\n\nA gradient transitioning between two colors along a line.\n\nSyntax\n------\n\n```xml\n\u003cLinearGradient startX=\"float\" startY=\"float\" endX=\"float\" endY=\"float\"\n colors=\"argb-color argb-color\" positions=\"float float\" /\u003e\n```\n\nAttributes\n----------\n\nThe `LinearGradient` element must contain the following attributes:\n\n`startX`\n\n: The x-coordinate for the start of the gradient line.\n\n This attribute is [transformable](/training/wearables/wff/common/transform/transform).\n\n`startY`\n\n: The y-coordinate for the end of the gradient line.\n\n This attribute is [transformable](/training/wearables/wff/common/transform/transform).\n\n`endX`\n\n: The x-coordinate for the end of the gradient line.\n\n This attribute is [transformable](/training/wearables/wff/common/transform/transform).\n\n`endY`\n\n: The y-coordinate for the end of the gradient line.\n\n This attribute is [transformable](/training/wearables/wff/common/transform/transform).\n\n`colors`\n\n: A space-separated list of colors. You must specify each color using either the\n ARGB format (`#ff000000` = opaque black) or the RGB format (`#000000` = black).\n\n`positions`\n\n: A space-separated list of floats. The relative positions \\[0..1\\] of each\n corresponding color in the colors attribute. If this is an empty string, the\n colors are distributed evenly along the gradient line.\n\nInner elements\n--------------\n\nThe `LinearGradient` element can contain :\n\n- Between 0 and 4 [`Transform`](/training/wearables/wff/common/transform/transform) elements.\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [SweepGradient](/training/wearables/wff/group/part/draw/gradient/sweep-gradient)\n- [Line](/training/wearables/wff/v2/group/part/draw/shape/line)\n- [Line](/training/wearables/wff/group/part/draw/shape/line)"]]