Demo entry 6656216

12

   

Submitted by 12 on Oct 30, 2017 at 09:03
Language: Java. Code size: 762 Bytes.

mFloatButton.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                int rawX= (int )event.getRawX();//RawX,RawY 相对于屏幕位置坐标  X,Y 相对于容器的位置坐标
                int rawY =(int )event.getRawY();
                switch (event.getAction()){
                    case MotionEvent.ACTION_MOVE: {
                        mLayoutParams.x = rawX;
                        mLayoutParams.y = rawY;
                        mWindowManager.updateViewLayout(mFloatButton, mLayoutParams);
                        break;
                    }
                    default:
                        break;
                }
               return false;
            }
        });

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).