ImageView imageView = findViewById(R.id.imageView); imageView.setTranslationY(100f); // Moves the image 100 pixels down
TextView textView = findViewById(R.id.textView); textView.animate().translationY(200f).start(); // Animates the TextView to move to 200 pixels downIn this example, we retrieve a TextView object and create an animation to set its vertical translation to 200 pixels. The animation will start immediately. Package library: android.view.animation Note: The setTranslationY method is available in the View class, but we can also create animations using the animate method and chaining the translationY method to it.