i want to add a view to a relativelayout. this view must be added to a specified position.
i have this:
int x = ...;
int y = ...;
button.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
int x = (int) event.getRawX();
int y = (int) event.getRawY();
v.layout(x, y, x + v.getWidth(), y + v.getHeight());
return true;
}
});
relativelayout.addView(button);
button.layout(x, y, x + button.getWidth(), y + button.getHeight());
the ontouchlistener works great.. the view stays with my finger. however the startpostion is always 0, 0... it doesn't matter what my x and y is.
anyone a idee?