There are two adjacent graphic buttons. If I use the method of calculation of the coordinates touch TouchEvent
, I have to create a large array of coordinates. Maybe there is another method?
Probably not the best solution but you could overlap two buttons each representing a part of the image(the black or white) and make the rest of the Button
's image transparent(the images will have the same dimensions for both buttons). You'll also need to extend the Button
class to override how the onTouchEvent
method handles the touch events, depending on the point where the touch happened being a transparent point or an "image" point. I've made a small sample project obtaining a Button
with two parts like below(ignore my design skills):
You can find the project here, it's pretty self explanatory. See if it helps you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With