android图片处理之让图片一直匀速旋转
作者:dl10210950 时间:2021-07-13 02:33:38
本文是在我的文章android图片处理,让图片变成圆形 的基础上继续写的,可以去看看,直接看也没关系,也能看懂
1、首先在res文件夹下创建一个名字为anim的文件夹,名字不要写错
2、在anim里面创建一个xlm文件:img_animation.xml,这个名字随便写都可以,注意不要大写,里面的代码如下:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<rotate
android:duration="5000"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="-1"
android:repeatMode="restart"
android:toDegrees="360" />
</set>
具体含义是:
duration:时间</span>
fromDegrees="0": 从几度开始转</span>t
oDegrees="360" : 旋转多少度</span>
pivotX="50%:旋转中心距离view的左顶点为50%距离,
pivotY="50%: 距离view的上边缘为50%距离
repeatCount="-1":重复次数,-1为一直重复
repeatMode="restart":重复模式,restart从头开始重复
布局文件代码没变,依旧是:放一个控件就行了
</
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff00ff"
>
<com.example.circleimageview.CircleImageView
android:id="@+id/imageview"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:src="@drawable/control_image"
/>
</RelativeLayout>
你也可以写成一个普通的控件都可以实现旋转
<span style="font-family: Arial, Helvetica, sans-serif;">package com.example.circleimageview;</span>import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView imageView = (ImageView) findViewById(R.id.imageview);
//动画
Animation animation = AnimationUtils.loadAnimation(this, R.anim.img_animation);
LinearInterpolator lin = new LinearInterpolator();//设置动画匀速运动
animation.setInterpolator(lin);
imageView.startAnimation(animation);
}
}
是不是很简单,运行效果如下:录制的有点问题,实际上是匀速地。
标签:android,图片旋转,图片处理
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
C#序列化成XML注意细节
2023-04-20 01:07:00
Android App中实现相册瀑布流展示的实例分享
2022-05-07 05:02:05
![](https://img.aspxhome.com/file/2023/9/104679_0s.png)
C#隐式运行CMD命令(隐藏命令窗口)
2023-05-03 17:41:32
![](https://img.aspxhome.com/file/2023/8/111218_0s.png)
使用Java编写一个简单的Web的监控系统
2023-02-18 04:00:19
![](https://img.aspxhome.com/file/2023/2/108222_0s.png)
Android中关于百度糯米app关闭网页或窗口的方法(99%人不知)
2023-02-18 00:23:49
![](https://img.aspxhome.com/file/2023/6/138706_0s.png)
c#.net多线程编程教学——线程同步
2021-12-27 06:03:50
springboot中filter的用法详解
2022-04-02 19:52:37
Android应用创建桌面快捷方式代码
2022-03-03 00:51:44
SpringBoot 文件上传和下载的实现源码
2021-05-28 14:12:46
![](https://img.aspxhome.com/file/2023/1/85531_0s.png)
浅谈spring的重试机制无效@Retryable@EnableRetry
2021-12-12 10:42:57
![](https://img.aspxhome.com/file/2023/5/62165_0s.jpg)
Spring高阶用法之自定义业务对象组件化
2022-02-18 07:48:55
C#键值对容器的介绍
2023-04-14 12:26:56
简单聊聊c# 事件
2022-03-05 06:16:52
![](https://img.aspxhome.com/file/2023/9/78189_0s.png)
Java模拟死锁发生之演绎哲学家进餐问题案例详解
2022-10-09 22:52:44
Android编程实现XML解析与保存的三种方法详解
2022-04-15 00:39:01
![](https://img.aspxhome.com/file/2023/5/125365_0s.png)
java.lang.NoClassDefFoundError错误解决办法
2021-12-29 03:52:27
C语言中的回调函数实例
2021-09-27 08:37:12
C#连接ODBC数据源的方法
2023-04-20 07:30:33
Springboot+SpringSecurity+JWT实现用户登录和权限认证示例
2021-11-14 11:06:11
![](https://img.aspxhome.com/file/2023/3/71583_0s.png)
Unity实现10天签到系统
2022-07-11 23:40:01
![](https://img.aspxhome.com/file/2023/0/89820_0s.jpg)