Android examples for Graphics:Canvas
is Touch In Circle Button
//package com.java2s; public class Main { public static boolean isTouchInCircleButton(int buttonWidth, int buttonHeight, int touchX, int touchY) { int buttonCenterX = buttonWidth / 2; int buttonCenterY = buttonHeight / 2; int touchDifferenceToMidX = Math.abs(touchX - buttonCenterX); int touchDifferenceToMidY = Math.abs(touchY - buttonCenterY); int touchRadius = (int) Math.sqrt(touchDifferenceToMidX * touchDifferenceToMidX + touchDifferenceToMidY * touchDifferenceToMidY); int radiusButton; if (buttonHeight > buttonWidth) { radiusButton = buttonWidth / 2; } else {//from w w w .jav a 2 s. c om radiusButton = buttonHeight / 2; } return (touchRadius <= radiusButton); } }