我創(chuàng)建了一個(gè)相對(duì)布局,當(dāng)我觸摸它時(shí),它會(huì)改變按鈕的位置。使用 OnTouchListener。但我希望當(dāng)我釋放按鈕 (ACTION_UP) 時(shí),它會(huì)在此操作之前轉(zhuǎn)到它自己的位置。誰(shuí)能幫幫我嗎?我的代碼:(在創(chuàng)建里面)...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