Reputation: 906
I have two png-images for the pressed and released state of a button. I'd like to build a button that accomplishes the following:
As you can see, the button is not rectangular, so the last point mentioned above might be tricky.
I already tried to use an ImageButton
and managed to meet point 1, but I failed at point 2.
Is there another View
I can use, that does the work for me? If not, could you hint me what techniques I should look into to solve this?
Upvotes: 0
Views: 99
Reputation: 28
If you use setBackground = "#0xxx"; on button in xml file the borders will desappear. Basically making it transparent using alpha
android:setBackground = "#0AAA"
Upvotes: 0
Reputation: 481
[Edit] for third part- follow this https://stackoverflow.com/a/8086317/3811198 in short
Use a TouchListener instead of ClickListener
Inside the listener, if the event is MotionEvent.ACTION_DOWN, get the touch coordinates
Check the image's pixel at the coordinates you obtained earlier; if the pixel is not transparent, consider the button was clicked, otherwise ignore the event.
Upvotes: 1
Reputation: 1902
Just use ImageView
One image set as background, second as src. And it resolve all your problems
Upvotes: 1