Code example for ViewGroup.MarginLayoutParams

0
					int h = getWindowManager().getDefaultDisplay().getHeight() - 128;
					if (x > w) x = w;
					if (y > h) y = h;
					 
					RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams 
							(new ViewGroup.MarginLayoutParams
									(RelativeLayout.LayoutParams.WRAP_CONTENT, 
											RelativeLayout.LayoutParams.WRAP_CONTENT));
			        lp.setMargins(x, y, 0, 0);
			        selected_item.setLayoutParams(lp);
			    } 
				if (event.getActionMasked() == MotionEvent.ACTION_UP) {
					selected_item = null;
				} 
				return true; 
			} 
		}); 
    } 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE