D
D
Dmitry2021-01-30 18:00:45
Java
Dmitry, 2021-01-30 18:00:45

How to set a border to an object when animating it inside a Layout?

Inside ConstraintLayoutwith the name colo = findViewById(R.id.colo);there are several objects that are constantly in motion, for example:

button1 = ObjectAnimator.ofPropertyValuesHolder(pr1,
  PropertyValuesHolder.ofFloat("x", 0, 850),
  PropertyValuesHolder.ofFloat("y", 140, 1050));
    button1.setDuration(6000 +this.a);
    button1.setRepeatCount(ObjectAnimator.INFINITE);
    button1.setRepeatMode(ObjectAnimator.REVERSE);

How to set movement coordinates (X, Y) based on the edges of the layout itself? I tried various experiments in the form colo.getWidth(), but apparently I'm doing something wrong.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question