1

Doing Android drag and drop, v is a "TextView" and it's as wide as screen width.

Is it possible to make the "shadowBuilder" below only drag "up and down" and not drag "left and right" ? Because I want it("shadowBuilder" or the TextView v) still fill the whole screen width during the drag process.

Thanks...

TextView textDrag;
...

DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(v); 
v.startDrag(null, shadowBuilder, v, 0); 



// here is it 
textDrag = (TextView) findViewById(R.id.textDrag);
        LayoutParams p = textDrag.getLayoutParams();
        p.width = displaymetrics.widthPixels * 3;
        textDrag.setLayoutParams(p);
        textDrag.setOnTouchListener(new OnTouchListener(){

            @Override
            public boolean onTouch(View v, MotionEvent motionEvent) {

                if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { 
                    //
                    DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(v); 
                    v.startDrag(null, shadowBuilder, v, 0);
                    v.setVisibility(View.INVISIBLE); 
                    return true; 

                } else { 
                    return false; 
                } 
            }
        });
andrewwang1TW
  • 119
  • 3
  • 14

0 Answers0