Hi, I thought about subclassing Drawable. But I can't seem to find a way to initiate a Drawable by itself e.g. Drawable newDrawable = new Drawable(); even thought Drawable() is mentioned as a constructor.
I have only seem getDrawable() as a method in ImageView. How do I just create a Drawable after I subclass it? Eclipse isn't giving me meaningful error message to proceed. Just an 'X' . On Sep 6, 3:13 pm, Dianne Hackborn <[email protected]> wrote: > If you want to do your own drawing, create a subclass of Drawable and draw > whatever you want when called. > > > > > > On Sat, Sep 5, 2009 at 6:37 PM, 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? > > -- > Dianne Hackborn > Android framework engineer > [email protected] > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. All such > questions should be posted on public forums, where I and others can see and > answer them. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

