Android-动画效果
来源:互联网 发布:程序员 计算器 编辑:程序博客网 时间:2024/06/08 06:23
目标效果:
通过十二个图片进行不断地切换,形成动画效果。
1.activity_main.xml页面:
<?xml version="1.0"?><RelativeLayout xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/mainbackgroud" tools:context="com.example.waiworld.MainActivity$PlaceholderFragment" > <ImageView android:id="@+id/ivLight" android:layout_width="400dp" android:layout_height="300dp" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:background="@drawable/a4" /></RelativeLayout>
2.res目录下新建drawable文件夹,文件夹中创建frame.xml页面。
frame.xml页面:
<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/a1" android:duration="50"></item><item android:drawable="@drawable/a2" android:duration="50"></item> <item android:drawable="@drawable/a3" android:duration="50"></item><item android:drawable="@drawable/a4" android:duration="50"></item> <item android:drawable="@drawable/a5" android:duration="50"></item><item android:drawable="@drawable/a6" android:duration="50"></item> <item android:drawable="@drawable/a7" android:duration="50"></item><item android:drawable="@drawable/a8" android:duration="50"></item> <item android:drawable="@drawable/a9" android:duration="50"></item><item android:drawable="@drawable/a10" android:duration="50"></item> <item android:drawable="@drawable/a11" android:duration="50"></item><item android:drawable="@drawable/a12" android:duration="50"></item> </animation-list>
3.MainActivity.class页面;
package com.example.donghua;import android.app.Activity;import android.graphics.drawable.AnimationDrawable;import android.os.Bundle;import android.widget.ImageView;public class MainActivity extends Activity {private ImageView ivLight; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); init(); }private void init() {ivLight=(ImageView) findViewById(R.id.ivLight);}@Overridepublic void onWindowFocusChanged(boolean hasFocus) {super.onWindowFocusChanged(hasFocus);ivLight.setBackgroundResource(R.drawable.frame); //使用动画页面AnimationDrawable anim = (AnimationDrawable) ivLight.getBackground();anim.start(); //开始动画}}
4.代码素材:点击打开链接
0 0
- Android动画---Animation动画效果
- Android 动画效果 --Animation 动画
- Android 动画效果 --Animation 动画
- Android 动画效果 --Animation 动画
- Android 动画效果 --Animation 动画
- Android 动画效果 --Animation 动画
- Android 动画效果 --Animation 动画
- android 动画效果
- Android 动画效果 --Animation
- Android 动画效果 --Animation
- Android动画效果
- Android 动画效果
- android动画效果
- Android 动画效果 --Animation
- Android Animation动画效果
- android基础--动画效果
- android Animation 动画效果
- android PopupWindow 动画效果
- Peterson算法
- 转换器 Convert 示例 WPF
- Machine Learning -- Linear Regression with Multiple Variables(Andrew Ng)
- java 基础 ---final
- ConditionalRemoval移除离群点
- Android-动画效果
- 用C#做个简单的登录界面
- hdu 1069 动规 Monkey and Banana
- linux tab 不能自动补全 上下键乱码
- Leetcode-403.Frog Jump(青蛙跳石头)
- 排序(3)--快速排序
- flume-ng单节点搭建
- 蓝桥杯_C语言_本科B——李白打酒
- VoxelGrid滤波器对点云降采样,并使用PCLVisulizer进行显示