Search code examples
androidviewmove

Android: how to move standard elements (like EditText) by touch event?


I can override onTouchEvent, but there is no x and y coordinates to set in the EditText or usual View.


Solution

  • You will need to adjust the rules of whatever container (e.g., RelativeLayout) holds the widget to be whatever it is you want it to be as a result of the onTouchEvent(). Usually, this is accomplished by adjusting the container-specific LayoutParams associated with the widget being moved.