/** Draws all buttons. */ private void drawButtons() { layout.removeAllViews(); Log.i("Player", bList.size() + " boutons"); for (VirtualButton b : bList) { Helper.setLayoutPosition(this, b, b.getPosX(), b.getPosY()); layout.addView(b); } }
public static void dragVirtualButton(VirtualButton v, MotionEvent event) { float x, y; int action = event.getActionMasked(); switch (action) { case (MotionEvent.ACTION_DOWN): case (MotionEvent.ACTION_MOVE): // Calculation of the new view position x = (v.getLeft() + event.getX() - v.getWidth() / 2) / v.getResources().getDisplayMetrics().widthPixels; y = (v.getTop() + event.getY() - v.getHeight() / 2) / v.getResources().getDisplayMetrics().heightPixels; Helper.setLayoutPosition((Activity) v.getContext(), v, x, y); v.setPosX(x); v.setPosY(y); return; default: return; } }
public VirtualButton_Debug(Context context, VirtualButton b) { super(context, b.getKeyCode(), b.getCharButton(), b.getPosX(), b.getPosY()); }