博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android淡入淡出动画_在Android中淡入动画示例
阅读量:2527 次
发布时间:2019-05-11

本文共 2942 字,大约阅读时间需要 9 分钟。

android淡入淡出动画

1) XML File: activity_main

1)XML文件:activity_main

In the above code in every ImageView you will find android:src="@drawable/tigress" shows an error. Actually the error is concern about image/images. The particular images I use in this article will not be there in your computer, so first you have to copy your own images from your computer to ‘drawable’ folder in android studio and also write the same spelling of image in android:src="@drawable/your_image_name".

在每个ImageView中的上述代码中,您会发现android:src =“ @ drawable / tigress”显示错误。 实际上,该错误与图像有关。 我在本文中使用的特定图像不会在您的计算机中出现,因此首先您必须将计算机中的图像复制到android studio中的“ drawable”文件夹中,并且还要在android:src =“中写入相同的图像拼写: @ drawable / your_image_name” 。

Android - Fade In Example 0

Here in ‘drawable’ folder you should copy your images which you would like to see in animation. As you copy your images, in drawble, red color will change in green color android:src="@drawable/your_image_name ". Error removes.

在“可绘制”文件夹中,您应该复制想要在动画中看到的图像。 复制图像时,在drawble中,红色将变为绿色android:src =“ @ drawable / your_image_name” 。 错误消除。

2) File: MainActivity.java

2)文件:MainActivity.java

package com.example.faraz.Animation_Example;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.animation.Animation;import android.view.animation.AnimationUtils;import android.widget.ViewFlipper;public class MainActivity extends AppCompatActivity {
Animation fade_in, fade_out; ViewFlipper viewFlipper; @Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewFlipper= (ViewFlipper) this.findViewById(R.id.backgroundViewFlipper1); fade_in= AnimationUtils.loadAnimation(this,android.R.anim.fade_in); fade_out=AnimationUtils.loadAnimation(this,android.R.anim.fade_out); viewFlipper.setAnimation(fade_in); viewFlipper.setAnimation(fade_out); viewFlipper.setAutoStart(true); viewFlipper.setFlipInterval(5000); viewFlipper.startFlipping(); }}

In android, there are many possible ways to make ‘fade in’ animation and here I used alpha tag and it is one the easy and most used ways of making animation. For the fade in animation using alpha tag you have to create an anim folder in your res directory.

在android中,有很多方法可以制作“淡入”动画,在这里我使用了alpha标记,这是制作动画最简单且最常用的方法之一。 对于使用alpha标签的淡入动画,您必须在res目录中创建一个anim文件夹。

Android - Fade In Example 1

After creating anim folder in res/ directory and also create fadein.xml file in res/anim/ directory and place the following content.

在res /目录中创建anim文件夹,并在res / anim /目录中创建fadein.xml文件后,放置以下内容。

3) XML File: fadein.xml

3)XML文件:fadein.xml

Output: After executing your code on your device/virtual device, you get animated images.

输出:在设备/虚拟设备上执行代码后,您将获得动画图像。

翻译自:

android淡入淡出动画

转载地址:http://rmxzd.baihongyu.com/

你可能感兴趣的文章
Java Socket总结
查看>>
法语学习笔记
查看>>
使用css的类名交集复合选择器 《转》
查看>>
[USACO18DEC]The Cow Gathering
查看>>
情感分析-英文电影评论
查看>>
王者荣耀游戏服务器架构的演进读后感
查看>>
关于ajax请求controller返回中文乱码的解决方法!
查看>>
Objective-C 和 Core Foundation 对象相互转换的内存管理总结
查看>>
IOS音频1:之采用四种方式播放音频文件(一)AudioToolbox AVFoundation OpenAL AUDIO QUEUE...
查看>>
Linux nmon 命令
查看>>
使用 urllib 构造请求对象
查看>>
sql server book
查看>>
长亭技术专栏 安全攻防技术分享
查看>>
sql server dba
查看>>
visualvm
查看>>
docker(4):coreos+docker+rancher真厉害
查看>>
设计模式之代理模式,学习笔记
查看>>
在Qsys中创建用户自定义IP
查看>>
【leetcode】Container With Most Water
查看>>
Python -- machine learning, neural network -- PyBrain 机器学习 神经网络
查看>>