Realizing such a thing. When you touch the screen, a TextView added to it, later, if you touch the TextView , it will be moved by finger. To do this, implemented such a handler.

 OnTouchListener t = new OnTouchListener(){ public boolean onTouch(View v,MotionEvent event) { // TODO: Implement this method //return super.onTouchEvent(event); int x = Math.round(event.getX()); int y = Math.round(event.getY()); b.setText(x +" " +y); switch(event.getAction()){ case MotionEvent.ACTION_DOWN: if(v instanceof AbsoluteLayout){ add(x,y,this);} break; case MotionEvent.ACTION_MOVE: if(v instanceof TextView){ v.setX(x); v.setY(y); } break; } return true; } }; 

This handler is assigned to Layout and created by TextView . It seems everything works, but the problem is that when TextView scrolled, it strangely twitches up and down, although it moves around with a finger. What could be the problem?

  • Those. Do you have text height more than TextView height? If yes, then try to wrap it in a ScrollView and set the height in WrapContent - Juriy Spb
  • I think the problem is different. The fact is that since the handler is assigned to both the layer and TextVieq at the same time it sends touch coordinates to the layer, then inside the TextView, hence the shifts - user186301
  • Obviously, IMHO, that in the presence of a conflict scrolled and your listener. Because Because TextView is implemented worse than ScrollView, this can help. Generally scrolling text by textView is a bad idea. - Yuriy SPb

0