3

I want to make a stroke that has a gradient on the stroke and use the stroke as a background for a selected button. Is this possible using a <shape> or will I need to use a 9-slice image?

I can connect the parts, I just don't know that a gradient on a <shape> is possible, but if it is I'd rather do that than create a png image.

1 Answer 1

7

Shape (rectangle) supports a gradient fill. You can also round the corners to get a nice toolbar button effect.

I don't think that stroke supports a gradient, but if you want a gradient stroke around your button you can create two layered rectangles - the first one using your gradient and the second using a solid or a different gradient sized to be 2 pixels smaller in height and width.

Sign up to request clarification or add additional context in comments.

3 Comments

I dare say your answer encompasses the closes thing i'm going to find. Thanks for your answer!
Just as an fyi: I myself most often use the 9patch png for backgrounds on buttons and custom "cells" (just a personal preference - or bad habit probably :-). But gradients are definitely more efficient and easier to modify.
I think you're right. 9-slice / 9patch is something I've used before, I just wanted to see if there was another way.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.