Create an Android ImageButton with a Shape -


I have an image button and want to scale the buttons to different sizes, which means that an image is the right choice is not. So I was thinking about a custom shape as the source of an image baton.

I like the button to look like this:

Enter image details here

I started with this, but stuck with the rotated stuff:

   & Lt; Rotate Android: fromDegrees = "90" Android: toDegrees = "135" & gt; & Lt; Size Android: shape = "row" & gt; & Lt; Stroke Android: width = "2dp" Android: color = "@ color / red" & gt; & Lt; / Stroke & gt; & Lt; / Size & gt; & Lt; / Rotate & gt; & Lt; Padding android: bottom = "7dp" Android: left = "7dp" Android: right = "7dp" android: top = "7dp" /> & Lt; / Size & gt;   

It is not rotated anyway as I expected. Maybe I'm completely wrong and need a push in the right direction. :-) Thanks.

Did you consider using bitmap and using bitmap based on your needs Is scaled. Scalebitmap (...) method to create You can easily convert it to a bitmapraudable and then assign this bitmap driver as the background of the button (name-by-the-button). Setbackgrounddriver (nameOfBitmapDrawable);

So all you have to do is save that picture (one of your posts) as a dry (perhaps transparent PNG) and then convert that bit to a bitmap. From there, you have to follow the steps outlined above hope that it helps.

Comments