android淡入淡出动画_在Android中淡入动画示例

android淡入淡出动画

1) XML File: activity_main

1)XML文件:activity_main

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.faraz.Animation_Example.MainActivity">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</LinearLayout>
<ViewFlipper
android:id="@+id/backgroundViewFlipper1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/backgroundImageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="@drawable/tiger_2"
android:adjustViewBounds="true" />
<ImageView
android:id="@+id/backgroundImageView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="@drawable/tigertiger"
android:adjustViewBounds="true"/>
<ImageView
android:id="@+id/backgroundImageView3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="@drawable/white2"
android:adjustViewBounds="true"/>
<ImageView
android:id="@+id/backgroundImageView4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="@drawable/white4"
android:adjustViewBounds="true"/>
<ImageView
android:id="@+id/backgroundImageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/white_tiger_copy"
/>
<ImageView
android:id="@+id/backgroundImageView6"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="@drawable/tiger" 
android:adjustViewBounds="true"/>
<ImageView
android:id="@+id/backgroundImageView7"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="@drawable/tigress"
android:adjustViewBounds="true"/>
<ImageView
android:id="@+id/backgroundImageView8"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="@drawable/wildcat"
android:adjustViewBounds="true"/>
</ViewFlipper>
</android.support.constraint.ConstraintLayout>

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

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="2000"
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"/>
</set>

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

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

翻译自: https://www.includehelp.com/android/fade-in-animation-example.aspx

android淡入淡出动画

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/377837.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

[慢查优化]联表查询注意谁是驱动表 你搞不清楚谁join谁更好时请放手让mysql自行判定...

写在前面的话&#xff1a; 不要求每个人一定理解 联表查询(join/left join/inner join等)时的mysql运算过程&#xff1b; 不要求每个人一定知道线上&#xff08;现在或未来&#xff09;哪张表数据量大&#xff0c;哪张表数据量小&#xff1b; 但把mysql客户端&#xff08;如SQL…

四、梯度下降归一化操作

一、归一化 Ⅰ什么是归一化&#xff1f; 答&#xff1a;其实就是把数据归一到0-1之间&#xff0c;也就是缩放。 常用的归一化操作是最大最小值归一化&#xff0c;公式如下&#xff1a; 例如&#xff1a;1&#xff0c;3&#xff0c;5&#xff0c;7&#xff0c;9&#xff0c;10…

[转帖][强烈推荐]网页表格(Table/GridView)标题栏和列冻结(跨浏览器兼容)

GridView的标题栏、列冻结效果(跨浏览器版) 本文来源&#xff1a;http://blog.darkthread.net/blogs/darkthreadtw/archive/2009/02/18/supertable-plugin-for-jquery.aspx 稍早发表了GridView 的标题列冻结效果&#xff0c;足以满足工作上的需求&#xff0c;不过存在两个缺点:…

psu是什么电脑配件_PSU的完整形式是什么?

psu是什么电脑配件PSU&#xff1a;电源部门/公共部门事业 (PSU: Power Supply Unit / Public Sector Undertaking) 1)PSU&#xff1a;电源设备 (1) PSU: Power Supply Unit) PSU is an abbreviation of the "Power Supply Unit". PSU是“电源设备”的缩写 。 It is a…

【C++grammar】断言与表达式常量

目录1、常量表达式和constexpr关键字2、断言与C11的静态断言1.1. assert : C语言的宏(Macro)&#xff0c;运行时检测。1.2. assert()依赖于NDEBUG 宏1.3. assert 帮助调试解决逻辑bug &#xff08;部分替代“断点/单步调试”&#xff09;2.1static_assert (C11的静态断言 )2.2.…

一些又用的国内著名期刊

记&#xff1a; 电子学报、电子与信息学报、图像图形学报、自动化学报、计算机学报、软件学报、计算机研究与发展。转载于:https://www.cnblogs.com/nanyangzp/p/3322244.html

一、Arduino UNO R3将数据上传至云平台

一、准备工作 ①ESP12E Shield ②Arduino UNO R3开发板 ③把ESP12E Shield安装到Arduino UNO R3开发板上 ④登录物联网平台注册个账号&#xff0c;到时候需要使用。 ⑤记录下来你的Uid和key到时候会用到 ⑥创建个设备&#xff0c;用于测试 ⑦beyondyanyu为设备名&…

怎样做一个快乐的ASP.NET程序员

首先我想解释一下标题中两个关键字: "快乐", "ASP.NET程序员". 有的人想成为一个"杰出"的程序员, 或者"资深"的程序员, 简单来说就是"大牛"级的人物 -- 但是本文不是针对此种发展方向不是说我不鼓励大家朝这方向走, 而是对我…

__eq___C ++'and_eq'关键字和示例

__eq__"and_eq" is an inbuilt keyword that has been around since at least C98. It is an alternative to & (Bitwise AND Assignment) operator and it mostly uses for bit manipulations. “ and_eq”是一个内置关键字&#xff0c;至少从C 98起就存在。 它…

leetcode 93. 复原IP地址 思考分析

题目 给定一个只包含数字的字符串&#xff0c;复原它并返回所有可能的 IP 地址格式。 有效的 IP 地址 正好由四个整数&#xff08;每个整数位于 0 到 255之间组成&#xff0c;且不能含有前导 0&#xff09;&#xff0c;整数之间用 ‘.’ 分隔。 例如&#xff1a;“0.1.2.201” …

二、通过云平台反向控制Arduino UNO R3

该篇博文是在第一篇博文(一、Arduino UNO R3将数据上传至云平台)的基础上进行的 一、云平台发送指令反向控制Arduino UNO R3 ESP12E Shield开关都推到OFF&#xff08;要不然下载会报错&#xff09;&#xff0c;往Arduino UNO R3开发板上下载下面的代码 这段代码进行测试要点&…

使用MSBuild编译FsLex项目

FsLex FsYacc微软本身也提供了一个项目模板。但是这个项目模板是lex和yacc文件均包含。我想只适用lex&#xff0c;但是如果每次使用命令行也觉得不够方便&#xff0c;于是还是研究了一番MsBuild的使用。 使用msbuild hellp.fsproj /v:d 可以查看整个msbuild的流程&#xff0c;非…

Python字符串格式:%vs.format

Often the string formatters in python are referred to as old style and new style. The old-style is % and .format is known as the new style. python中的字符串格式化程序通常被称为旧样式和新样式。 旧样式为&#xff05; &#xff0c;. format被称为新样式。 Simple…

【C++grammar】代理构造、不可变对象、静态成员

目录1、Delegation Constructor&#xff08;代理构造&#xff09;1. What is delegating constructor? (什么是代理构造/委托构造)2. Avoiding recursive calls of target constructors (避免递归调用目标ctor)3. 委托构造的好处2、不可变对象和类1、如何让类成为“不可变类”…

paip.最新的c++ qt5.1.1环境搭建跟hello world

paip.最新的c qt5.1.1环境搭建跟hello world 作者Attilax &#xff0c; EMAIL:1466519819qq.com 来源&#xff1a;attilax的专栏 地址&#xff1a;http://blog.csdn.net/attilax 有一段时间没接触c了...今天下载新的qt下来研究一番.. qt的环境搭建有eclipseqtdtmingwqtl…

RFID模块+WIFI模块+振动传感器+有源蜂鸣器+舵机+Arduino UNO R3所构成的门禁系统模块

该系统模块主要由RFID模块WIFI模块振动传感器有源蜂鸣器舵机Arduino UNO R3组成的门禁系统模块。这里使用舵机充当门锁&#xff0c;用户可以刷卡开门&#xff0c;也可以通过APP控制舵机状态达到开门的效果。若有不法分子想要强行进入室内&#xff0c;对门进行撞击或者人为的破坏…

PushManager

http://suchandalex.googlecode.com/svn/trunk/beOui/beWe/client/Classes/PushNotificationManager.m转载于:https://www.cnblogs.com/vincent-lu/archive/2012/01/18/2325740.html

krsort_PHP krsort()函数与示例

krsortPHP krsort()函数 (PHP krsort() function) krsort() function is used to sort an associative array in descending order based on the keys, as we know that an associative array contains keys and values, this method sorts an array according to the keys. kr…

ESP12E Shield+Arduino UNO R3开发板+DHT11温湿度模块+双色LED灯+有源蜂鸣器+光敏电阻模块+I2CLCD1602液晶显示器所构成的室内检测系统

室内检测系统由ESP12E ShieldArduino UNO R3开发板DHT11温湿度模块双色LED灯有源蜂鸣器光敏电阻模块I2CLCD1602液晶显示器所构成。DHT11温湿度模块获取室内温湿度数据通过I2CLCD1602液晶显示器进行显示&#xff0c;另一方面通过ESP12E Shield将数据上传至云平台。光敏电阻进行捕…

输入输出函数:

一、printf函数&#xff1a;     printf("Hello World!\n");     printf("My age is %d\n",26);     int age 17;     printf("My age is %d\n",age);  %d 或 %i: 带符号 十进制整数。   %o:不带符号 八进制整数。   %x:…