How to detect objects and views inside an application?

I searched for this topic, but have not yet found a useful solution.

The following image describes that: -

enter image description here

After I touched the screen, the created ball.

The ball comes from the top of the screen and falls to the surface of the line, at the last moment the ball becomes stable on the line.

How to define this line?

What should I look for or what to use?

I appreciate any help.

+4
source share
2 answers

In order to revive the ball you need to take a step to check the battle.

  if(ball.getBounds().intersects(line.getBounds())
     ball.stop();

Android, , , , http://www.pontov.com.br/site/index.php/android/247-android-desenhando-na-tela

+3

, , .

startX, startY, endX endY.

X startX endX, Y , startY.

,

Line line = new Line(10,10, 80,80);

int startX=10, startY=10, endX = 80,endY=80;
int positionX=ball.getX(), positionY=ball.getY();

if( positionX <= startX && positionX <= endX && positionY <= startY )
    ball.stop();
+2

Source: https://habr.com/ru/post/1688188/


All Articles