我創建了一個相對布局,當我觸摸它時,它會改變按鈕的位置。使用 OnTouchListener。但我希望當我釋放按鈕 (ACTION_UP) 時,它會在此操作之前轉到它自己的位置。誰能幫幫我嗎?我的代碼:(在創建里面)...this.relative_layout.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { // TODO: Implement this method if(event.getAction() == event.ACTION_MOVE) { float x = event.getX(); float y = event.getY(); my_button.setX(x); my_button.setY(y); } else if(event.getAction() == event.ACTION_UP) /* here's the issue that I'm * asking for help about * What to do to return the button position back * Like it was? */ return true; } });
如何檢索按鈕位置?
慕田峪4524236
2022-12-21 10:13:49