I\'m trying to create an app that can move an ImageView
on your device like dragging and when I put like 75% of the ImageView
out of the screen show a
You can achieve this via this code.
DisplayMetrics metrics = getResources().getDisplayMetrics();
int windowWidth = metrics.widthPixels;
int windowHeight = metrics.heightPixels;
Now in your onTouch method, calculate if the target location exceeds the above dimensions.
if( currentXLocation + deltaX > windowWidth ){
// this will ensure that target location
// is always <= windowHeight
deltaX = windowWidth - currentXLocation;
} else if( currentXLocation + deltaX < 0){
deltaX = -(currentXLocation);
} else if (...){
// perform similar calculations for the rest
}