List of usage examples for android.widget RelativeLayout updateViewLayout
@Override public void updateViewLayout(View view, ViewGroup.LayoutParams params)
From source file:Main.java
public static void UpdateView(RelativeLayout panel, View v, int vw, int vh, int styles[][], int left, int top) { panel.updateViewLayout(v, GetRLP(vw, vh, styles, left, top)); }
From source file:Main.java
/** * // w w w . ja v a 2 s . c o m * @param panel * @param v * @param vw * @param vh * @param styles * @param left * @param top */ public static void UpdateView(RelativeLayout panel, View v, int vw, int vh, int styles[][], int left, int top) { panel.updateViewLayout(v, GetRLP(vw, vh, styles, left, top)); }
From source file:org.coursera.android.shift.ShiftIconFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.shift_menu, container, false); mHead = layout.findViewById(R.id.head); final RelativeLayout.LayoutParams iconParams; iconParams = (RelativeLayout.LayoutParams) mHead.getLayoutParams(); final GestureDetector gestureDetector = new GestureDetector(getActivity(), new SingleTapConfirm()); mHead.setOnTouchListener(new View.OnTouchListener() { private int initialX; private int initialY; private float initialTouchX; private float initialTouchY; @Override// ww w . jav a 2 s . c o m public boolean onTouch(View v, MotionEvent event) { final int yLimit = layout.getMeasuredHeight() - mHead.getMeasuredHeight(); final int xLimit = layout.getMeasuredWidth() - mHead.getMeasuredWidth(); // single tap if (gestureDetector.onTouchEvent(event)) { mShiftLauncherView.showShiftMenu(getActivity()); return true; } // drag icon switch (event.getAction()) { case MotionEvent.ACTION_DOWN: initialX = iconParams.leftMargin; initialY = iconParams.topMargin; initialTouchX = event.getRawX(); initialTouchY = event.getRawY(); return true; case MotionEvent.ACTION_CANCEL: return false; case MotionEvent.ACTION_UP: return true; case MotionEvent.ACTION_MOVE: int newX = initialX + (int) (event.getRawX() - initialTouchX); int newY = initialY + (int) (event.getRawY() - initialTouchY); iconParams.leftMargin = newX < 0 ? 0 : Math.min(newX, xLimit); iconParams.topMargin = newY < 0 ? 0 : Math.min(newY, yLimit); layout.updateViewLayout(mHead, iconParams); return true; } return false; } }); return layout; }