Reputation: 5391
As an exercise, I am trying to extend ImageButton
to add some features I think would be useful. One, in particular, is a drow shadow. I've hit the proverbial wall with this one.
It seems to me, that a class extending BitmapDrawable
is necessary. This class contains a Paint
object used to draw the bitmap to the screen. If I had access to this Paint
object... all I would have to do is call it's setShadowLayer()
method... but, alas, it is private
. There is a public
method, getPaint()
that will return the paint object, but any modifications to it would be useless unless there were a corresponding setPaint()
method. (There isn't.)
Currently, my thought process looks something like the following...
ShadowBitmapDrawable
which extends BitmapDrawable
BitmapDrawable
's Paint
object with Paint
's setShadowLayer()
method.ImageButton
class, call setImageDrawable(Drawable d)
, and pass it my ShadowBitmapDrawable
object.Step 2 is the road block. What can I do to change BitmapDrawable
's Paint
object? Note that I added my thought process only as an indicator of where I am in this problem. I am open to other suggestions.
Here are some references:
Drawable
to draw bitmaps)ImageButton
)
P.S. I have a bad feeling I already know the answer I'm going to get, and I'm not going to like it. Thought I'd post the question anyways and hope for the best.
Upvotes: 0
Views: 208
Reputation: 1006819
What can I do to change BitmapDrawable's Paint object?
Clone BitmapDrawable
into your project, refactor it into your own package, make the data member protected
(or provide a protected
setter or something), use your modified BitmapDrawable
, and test the heck out of it.
Upvotes: 1