Я вставил видео двух запущенных проектов.Моя конечная цель - достижение результата, подобного первому проекту.Я хочу, чтобы изображение вошло слева на экран, переместилось вправо и, наконец, заполнило экран и остановилось.В первом примере проекта, получив инструкции от друзей по переполнению стека, я наконец достиг желаемого результата.Но когда я копирую код во второй проект (мой основной проект), я получаю другой результат, и изображение останавливается в центре экрана.почему?
Я вставляю коды для первого проекта
https://youtu.be/UlKiAb4H9Dg
Второй макет второго проекта добавляется в конце кода
imageView.post(new Runnable() {
@Override
public void run() {
startImageAnimation();
}
});
private void startImageAnimation() {
ObjectAnimator animation = ObjectAnimator.ofFloat(imageView,
"translationX", -(imageView.getWidth()), 0);
animation.setDuration(3000);
animation.start();
}
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/grass"
android:id="@+id/image_anim"
/>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<ImageView
android:layout_width="156dp"
android:layout_height="153dp"
android:layout_gravity="center"
android:src="@drawable/awz" />
<TextView
android:id="@+id/text_logo_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="شرکت توسعه نیشکر و صنایع جانبی"
android:textSize="20sp" />
<TextView
android:id="@+id/text_logo_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="سامانه داده کاربر بیمه"
android:textSize="20sp" />
<ImageView
android:layout_width="156dp"
android:layout_height="153dp"
android:layout_gravity="center"
android:src="@drawable/bahrevar" />
<ImageView
android:id="@+id/image_anim_grass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/grass"
/>
</LinearLayout>