On Sep 6, 3:37 am, hc <[email protected]> wrote:
> Is it possible to convert a Canvas to Drawable?
>
> I may be really off in my solution, so if you have a better
> suggestion, please do tell me. This is what I'm trying to do.
>
> I'm trying to create a custom RadioButton. to set different states of
> the radio button, I need to use this parameter
>
> StateListDrawable drawables = new StateListDrawable();
> drawable.addState(............)
>
> and one of the parameter to addState is Drawable. I know I can easily
> provide an image file and use it as a Drawable, but I want to do some
> image manipulation to the image before using it.
>
> There is a tutorial in ApiDemo called AlphaBitmap. It uses the onDraw
> method of a View to change a PNG file to full red and draw something
> with a gradient. So I customized it to shade an icon with gradient. So
> the problem now is that this is a View, and the View works perfectly
> fine if I add this View to the main view. But i want to convert this
> View to Drawable so I can use it as one of the parameter in addState.
> What I really want to achieve is to have different colour shades for
> different state of the RadioButton without providing different images
> to do so.
>
> Is there a better solution?


if your RadioButton doesnt have any new functionality except different
color shades for different states you can easly extend Drawable and
override its onDraw(Canvas). this way you dont even have to extend
RadioButton, just setBackgroundDrawable(yourNewCustomDrawable)

pskink
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to