I have created a draggable view inside RelativeLayout. But it seems to go beyond the RelativeLayout.
I simply
You should use rootView.getX()
and rootView.getY()
as the left and top bounderies... and (rootView.getX() + rootView.getWidth())
as the right and (rootView.getY() + rootView.getHeight())
for the bottom boundary.
You have to write your boundary logic in onTouch() in the ACTION_MOVE case.
Hope this helps.