首页 > 解决方案 > 如何使背景图像缓慢向上移动

问题描述

我正在使用 Android Studio、Kotlin,我的活动文件是用 xml 编码的。


我希望我的应用程序中的背景慢慢向上移动。

https://youtu.be/_mg5WrvZr3g?t=26

^ 类似这样,但只有一层移动。

这就是我在我的活动 xml 文件中设置背景图像的方式:

<androidx.constraintlayout.widget.ConstraintLayout 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:background="@drawable/background01tilable"
    tools:context=".MainActivity">

这就是我为图像绘制的样子:

<bitmap
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/background01"
    android:tileMode="repeat"
    android:scaleType="center"
    android:layout_width="10dp"
    android:layout_height="50dp"
    />

我将如何制作缓慢移动的背景图像?

标签: xmlandroid-studiokotlin

解决方案


推荐阅读