发布于 2017-03-20 09:38:34 | 181 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

Android移动端操作系统

Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。


让图片一直匀速旋,这篇文章主要介绍了android图片处理之让图片一直匀速旋转的相关资料,感兴趣的小伙伴们可以参考一下

本文是在我的文章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);
 }

}

 是不是很简单,运行效果如下:录制的有点问题,实际上是匀速地。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持PHPERZ。



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务