How to set button by a contour polygon? Android

青春壹個敷衍的年華 提交于 2019-11-28 12:24:47

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!