I am writing a method that draws a layout ontop of buttons. My problem is with the position of the layout that I am creating on lower API's. On newer I am using the
setY() methods but since that is not working on lower I tried with setting the layout params as described here Android - Use of view.setX() and setY in api 8 but I am not getting the results I want. With this
int location = new int;
int x = location;
int y = location;
I am achieving this:
but if I use this code to support lower API's
relativeLayoutparams.leftMargin = x;
relativeLayoutparams.topMargin = y;
I am getting this as a result: incorrect
Any help would be appreciated.
For API 1:
int location = new int; button.getLocationOnScreen(location); int x = location; int y = location; borderRelativeLayout.offsetLeftAndRight(x - borderRelativeLayout.getLeft()); borderRelativeLayout.offsetTopAndBottom(y - borderRelativeLayout.getTop());
Did you consider a background drawable for desired effect?