Code example for AbsoluteLayout.LayoutParams

0
 
			@Override 
			public boolean onTouch(View v, MotionEvent event) {
				if (current != null) // any event from down and move
				{ 
					LayoutParams lp = new LayoutParams(
							LayoutParams.WRAP_CONTENT,
							LayoutParams.WRAP_CONTENT, (int) event.getX()
									- current.getWidth() / 2, (int) event.getY()
									- current.getHeight() / 2);
					current.setLayoutParams(lp);
 
				} 
				if (event.getAction() == MotionEvent.ACTION_UP) {
					current = null;
 
				} 
				return true; 
			} 
		});