安卓之动画制作

1.知识图谱

(补间动画和帧动画)



1.补间动画的效果图:

(alpha透明度)                                                                                     (ratate旋转)


XML代码:

MainActivity.xml代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns: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="com.example.cookie.android0626animation.MainActivity"><!--alpha透明度--><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/eat1"android:id="@+id/iv_main_image"android:layout_marginTop="100dp"/><!--rotate旋转--><!--scale缩放--><!--translate移动--><HorizontalScrollViewandroid:layout_width="match_parent"android:layout_height="wrap_content"><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"><Buttonandroid:layout_width="0dp"android:layout_height="wrap_content"android:id="@+id/bu_image_alpha"android:layout_weight="1"android:onClick="operation"android:text="alpha"/><Buttonandroid:layout_width="0dp"android:layout_height="wrap_content"android:id="@+id/bu_image_rotate"android:layout_weight="1"android:onClick="operation"android:text="rotate"/><Buttonandroid:layout_width="0dp"android:layout_height="wrap_content"android:id="@+id/bu_image_scale"android:layout_weight="1"android:onClick="operation"android:text="scale"/><Buttonandroid:layout_width="0dp"android:layout_height="wrap_content"android:id="@+id/bu_image_translate"android:layout_weight="1"android:onClick="operation"android:text="translate"/><Buttonandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:text="all"android:onClick="operation"android:id="@+id/bu_image_all"/></LinearLayout></HorizontalScrollView></LinearLayout>



在Project里找到你写的现在写动画的项目,然后在res下新建一个anim文件夹,在该文件夹下新建所需动画效果的xml类

iv_alpha.xml代码

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"android:fromAlpha="1.0"android:toAlpha="0.3"android:duration="3000"android:fillAfter="true"></alpha>



iv_rotate.xml代码

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"android:fromDegrees="0"android:toDegrees="720"android:pivotX="50%"android:pivotY="50%"android:duration="3000"android:fillAfter="true"></rotate>


iv_scale.xml代码

<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"android:fromXScale="100%"android:fromYScale="100%"android:toXScale="50%"android:toYScale="50%"android:pivotX="50%"android:pivotY="50%"android:duration="3000"android:fillAfter="true"></scale>



iv_translate.xml代码

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"android:fromXDelta="0"android:fromYDelta="0"android:toXDelta="50%"android:toYDelta="50%"android:duration="3000"android:fillAfter="true"></translate>


iv_all.xml代码

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"android:duration="3000"android:fillAfter="true"><alphaandroid:fromAlpha="1.0"android:toAlpha="0.3"></alpha><rotateandroid:fromDegrees="0"android:toDegrees="360"android:pivotX="50%"android:pivotY="50%"></rotate><scaleandroid:fromXScale="100%"android:fromYScale="100%"android:toXScale="50%"android:toYScale="50%"android:pivotX="50%"android:pivotY="50%"></scale><translateandroid:fromXDelta="0"android:fromYDelta="0"android:toXDelta="50%"android:toYDelta="50%"></translate></set>



MainActivity.java代码:

package com.example.cookie.android0626animation;import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;public class MainActivity extends AppCompatActivity {private ImageView iv_main_image;private Animation animation;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);iv_main_image = (ImageView) findViewById(R.id.iv_main_image);}public void operation(View view){switch (view.getId()) {case R.id.bu_image_alpha://加载动画animation = AnimationUtils.loadAnimation(this, R.anim.iv_alpha);//给图片开启动画效果iv_main_image.startAnimation(animation);break;case R.id.bu_image_rotate://加载动画animation=AnimationUtils.loadAnimation(this,R.anim.iv_rotate);//给图片开启动画效果iv_main_image.startAnimation(animation);break;case R.id.bu_image_scale:animation=AnimationUtils.loadAnimation(this,R.anim.iv_scale);//给图片开启动画效果iv_main_image.startAnimation(animation);break;case R.id.bu_image_translate://加载动画animation=AnimationUtils.loadAnimation(this,R.anim.iv_translate);//给图片开启动画效果iv_main_image.startAnimation(animation);break;case R.id.bu_image_all://加载动画animation=AnimationUtils.loadAnimation(this,R.anim.iv_all);//给图片开启动画效果iv_main_image.startAnimation(animation);break;}}}


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

如若内容造成侵权/违法违规/事实不符,请联系瞎胡闹网进行投诉反馈,一经查实,立即删除!

相关文章

Android BT

整个bluedroid可以分为两大模块&#xff1a;BTIF&#xff0c;BTE BTIF&#xff1a;提供bluedroid对外的接口;作为bluedroid与上层的framework提供interface。所以它处于bluedroid的顶层。 BTE&#xff1a;bluedroid的内部处理&#xff0c;又细分为BTA&#xff0c;BTU&#xf…

04.BT下载

04.BT下载 下载&#xff0c;是很多网络用户必备的需求之一。以往我们使用现成工具迅雷&#xff0c;我们必须保持开机&#xff0c;会员&#xff0c;合法等等要求&#xff0c;但是依托服务器&#xff0c;我们其实也可以搭建BT下载工具&#xff0c;只要你的硬盘够用&#xff0c;把…

BackTrack5(BT5)各版本下载

BT5R3(最新版本)http://www.nigesb.com/backtrack-5-r3-released.html BT5R2 KDE版32位&#xff1a; http://ftp.halifax.rwth-aachen.de/backtrack/BT5R2-KDE-32.iso GNOME32位&#xff1a;http://ftp.halifax.rwth-aachen.de/backtrack/BT5R2-GNOME-32.iso BT5R1 KDE版32位…

mysql 存储用户头像_node+vue用户头像处理上传并保存

2017年7月14日19:21:29 &#xff0c;最近做个网站&#xff0c;需要有用户头像裁剪上传功能&#xff0c;具体流程是用户在本地选择图片&#xff0c;前端将图片裁剪好发给后端&#xff0c;后端接收到图片将它保存起来&#xff0c;并将信息存入数据库。 先说一下环境后端是express…

java 根据用户名生成头像。

先上效果图 自行根据需求修改代码 package com.space; import java.awt.*; import java.awt.geom.RoundRectangle2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.Random; import java.util.regex.Matcher; im…

支付宝小程序serverless---获取用户信息(头像)并保存到云数据库

支付宝小程序serverless—获取用户信息&#xff08;头像&#xff09;并保存到云数据库 博客说明 文章所涉及的资料来自互联网整理和个人总结&#xff0c;意在于个人学习和经验汇总&#xff0c;如有什么地方侵权&#xff0c;请联系本人删除&#xff0c;谢谢&#xff01; 我又回…

湘大 XTU OJ 1260 Completed String 题解(非常详细):建立数组下标和数组元素之间的映射关系 ~scanf

一、链接 1260 Completed String 二、题目 题目描述 给一个字符串&#xff0c;请判断字符串是否出现了所有的英文字母&#xff08;不区分大小写&#xff09;。 输入 每行一个只含英文字母的字符串&#xff0c;长度不超过1000。 输出 每行输出一个样例的结果&#xff0c…

openCV配置+cmake操作记录--Ubuntu 16.04版本

项目需要openCV相关操作,于是找了好多教程,琢磨了好久,写个笔记。 更新ubuntu上的一些库: sudo apt-get update sudo apt-get upgrade 安装一些库:(虽然我现在也不明白这玩意,我是纯小白/(ㄒoㄒ)/~~) sudo apt-get install cmake sudo apt-get install build-essen…

笔记2:openCV打开摄像头显示到QT的QLabel--Ubuntu系统

目的: 通过openCV调用摄像头,把捕捉到的画面显示到QT的QLabel控件上。 听起来很easy的样子,我的coding能力很弱,可以找个我是理学院出身的借口,但现实是谁会听你的借口呢,希望这笔记不是给我未来参考的,而是为了博未来的自己一笑,那样才能说明我是进步的哈。 效果:…

【二叉树】1-5,理论基础、前中后序遍历的递归法和迭代法、层序遍历

理论基础、前中后序遍历的递归法和迭代法、层序遍历 1&#xff0c;二叉树的种类满二叉树完全二叉树二叉搜索树平衡二叉搜索树 2&#xff0c;存储方式链式存储线式存储 3&#xff0c;二叉树的遍历深度优先搜索前序遍历&#xff08;递归法、迭代法&#xff09;中序遍历&#xff0…

fork创建多个子进程

fork创建多个子进程 示例代码 fork1.c #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h>int main(int argc,char **argv) {int i, j;pid_t pid;for (i 0; i < 3; i){pid fork();if (pid < 0){perror(&q…

苹果6换屏多钱_iPhone12屏幕维修多少钱 苹果12换屏价格汇总

苹果iPhone12系列手机如果屏幕坏了要维修换屏的话&#xff0c;需要多少钱呢&#xff0c;官方的换屏价格是多少&#xff0c;这里我们来了解下iPhone12系列手机官方渠道换屏价格。 1、iPhone12保外屏幕维修费用 2149元&#xff0c;iPhone12Pro屏幕维修费用2149元&#xff0c;由于…

合并两个有序链表

就像一个贪吃蛇将两个链表一一的吃进来 class Solution(object):def mergeTwoLists(self, list1, list2):""":type list1: Optional[ListNode]:type list2: Optional[ListNode]:rtype: Optional[ListNode]"""p ListNode(0)cur pwhile list1 a…

如何在CSS中水平居中一个元素?

聚沙成塔每天进步一点点 ⭐ 专栏简介⭐ 使用 margin: 0 auto⭐ 使用 Flexbox 布局⭐ 使用绝对定位和负边距⭐ 使用表格布局⭐ 使用网格布局⭐ 写在最后 ⭐ 专栏简介 前端入门之旅&#xff1a;探索Web开发的奇妙世界 记得点击上方或者右侧链接订阅本专栏哦 几何带你启航前端之旅…

Flink CDC系列之:TiDB CDC 导入 Elasticsearch

Flink CDC系列之&#xff1a;TiDB CDC 导入 Elasticsearch 一、通过docker 来启动 TiDB 集群二、下载 Flink 和所需要的依赖包三、在TiDB数据库中创建表和准备数据四、启动Flink 集群&#xff0c;再启动 SQL CLI五、在 Flink SQL CLI 中使用 Flink DDL 创建表六、Kibana查看Ela…

b站 APP 产品体验报告

参考链接 https://www.jianshu.com/p/3dda6a6f050e 虽然B站在很多情况下被认为其主要的用户群体是ACG&#xff08;Animation、Comic、Game&#xff09;爱好者&#xff0c;但现在随着其内容不断丰富&#xff0c;用户体验不断改良&#xff0c;用户群体也随之拓展。因此&#xff0…

最简单版B站视频下载

最近想在电脑端缓存一些b站的视频&#xff0c;发现缓存不了&#xff0c;手机端是可以缓存的&#xff0c;但是比如有些课程&#xff0c;还是直接在电脑缓存比较方便些&#xff0c;整了一个小时左右&#xff0c;终于解决了&#xff0c;今天出一篇博客分享一下&#xff0c;有需要的…

基于Cordova的 B站用户直播闹钟app(安卓版)

前言 本项目基于Cordova开发&#xff0c;打包的apk支持Android9&#xff0c;主要功能为 监听b站用户直播情况&#xff0c;开播进行闹钟提示 ps&#xff1a;目前版本还是有蛮多问题的&#xff0c;如有遇到可以及时反馈&#xff0c;我会想办法进行修复。 源码下载 码云 GitHub…

Android Compose——一个简单的Bilibili APP

Bilibili移动端APP 简介依赖效果登录效果WebView 自定义TobRow的Indicator大小首页推荐LazyGridView使用Paging3热门 排行榜搜索模糊搜索富文本 搜索结果视频详情合集 信息Coroutines进行网络请求管理&#xff0c;避免回调地狱添加suspendwithContext Git项目链接末 简介 此De…

仿B站web,APP,后台

体验地址 web端&#xff1a;http://82.157.168.147/ 安卓端&#xff1a;http://82.157.168.147:7000/bilibili/phone/app.html 测试账号&#xff1a;17627286393 密码:123456 仅测试使用&#xff0c;推荐使用自己的手机号&#xff0c;否则部分功能部分使用&#xff0c;请不要用…