Julian A.
Julian A.

Reputation: 11460

Draw line with faded ends

Is it possible in Android to programmatically draw a line using a path, such that the middle section is a solid color but both ends fade from that color to transparent? The path will be a series of calculated coordinates.

Upvotes: 1

Views: 1997

Answers (1)

Phantômaxx
Phantômaxx

Reputation: 38098

Yes, use a generic View widget with a drawable that contains a gradient as its background.

Make sure it extends to match_parent in the direction you want it to cut your layout and it's 1px tall or wide in the other dimension.

The gradient should be a simple linear gradient transparent to solid to transparent.

Here is a very nice tutorial.

Update: The above link is dead, try this one instead.

Upvotes: 6

Related Questions