android - 如何使用计时器更改图像

标签 android image

大家好 我必须对图片说 image1 和 image2 我想在计时器上显示两张图片,一次只能看到一张图片。两张图片重叠,也就是说,image1 在 image2 之上。

所以,如果我使用计时器,我希望能够一次显示一张图像。 我该怎么做呢。 我希望我清楚我的问题

最佳答案

将您的图像放在 Drawable 文件夹中。并在 drawable 文件夹中创建一个 splash.xml 文件,如下所示:

<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true"> <item android:drawable="@drawable/splash_1" android:duration="200" /> <item android:drawable="@drawable/splash_2" android:duration="200" /> <item android:drawable="@drawable/splash_3" android:duration="200" /> <item android:drawable="@drawable/splash_4" android:duration="200" /> <item android:drawable="@drawable/splash_5" android:duration="200" /> </animation-list>

在你的 Activity 课上

setContentView(R.layout.splashscreen);

    final ImageView splashImage = (ImageView) findViewById(R.splash.ImageView);
    splashImage.setBackgroundResource(R.drawable.splash);
    splashAnimation = (AnimationDrawable) splashImage.getBackground();
    splashAnimation.start();

关于android - 如何使用计时器更改图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3395328/

相关文章:

java - 从android中的url加载图像时发生类转换异常

java - 从 onActivityResult() 调用时,notifyDataSetChanged() 不适用于我的 RecyclerView.Adapter

c++ - Qt中显示图像的正确方法

android - 从 SQLite DB 中获取图像并在 WebView 中显示它们的最佳方法 (Android)

安卓分析APK

java - 如何检查手机日期是否为当前日期

css - 在 symfony 中为图像添加修订号以避免浏览器缓存

javascript - 如何使用map函数在第一个react组件中添加图像并忽略其余组件

javascript - 使用 jQuery 检查 img src 是否为空

java - 在 Android 的房间数据库中插入复合键的重复值后应用程序崩溃