I have the following XML:
Looks like you have so e typos that cause your problem.
Change
if (x>0 || x<bm.getWidth() || y>0 || y<bm.getHeight())
into this
if (x>0 && x<bm.getWidth() && y>0 && y<bm.getHeight())
Maybe that'll fix your issue.