Code example for FrameLayout.LayoutParams

Methods: setMargins

0
					Vibrator vib = (Vibrator)(getActivity().getSystemService(Context.VIBRATOR_SERVICE));
					vib.vibrate(100);
					start = false;
				} 
				 
                LayoutParams params = new LayoutParams(v.getWidth(),  v.getHeight());
                //set the margins. Not sure why but multiplying the height by 1.5 seems to keep my finger centered on the button while it's moving 
                params.setMargins((int)me.getRawX() - v.getWidth()/2, (int)(me.getRawY() - v.getHeight()), (int)me.getRawX() - v.getWidth()/2, (int)(me.getRawY() - v.getHeight()*1.5));
                v.setLayoutParams(params);
             } 
			else if (me.getAction() == MotionEvent.ACTION_UP)
			{ 
				start = false;
				 
				// consume the event if the user had been dragging the button around 
				// otherwise let the method return false so that the onClick is detected 
				if (System.currentTimeMillis() - firstDown > HOLD_LENGTH)
					return true; 
			} 
             return false; 
        }