欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android圖片處理之讓圖片一直勻速旋轉(zhuǎn)

 更新時(shí)間:2016年08月24日 17:18:31   作者:dl10210950  
讓圖片一直勻速旋,這篇文章主要介紹了android圖片處理之讓圖片一直勻速旋轉(zhuǎn)的相關(guān)資料,感興趣的小伙伴們可以參考一下

本文是在我的文章android圖片處理,讓圖片變成圓形 的基礎(chǔ)上繼續(xù)寫的,可以去看看,直接看也沒關(guān)系,也能看懂 

1、首先在res文件夾下創(chuàng)建一個(gè)名字為anim的文件夾,名字不要寫錯(cuò) 
2、在anim里面創(chuàng)建一個(gè)xlm文件:img_animation.xml,這個(gè)名字隨便寫都可以,注意不要大寫,里面的代碼如下:

<?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:時(shí)間</span>

fromDegrees="0":  從幾度開始轉(zhuǎn)</span>t

oDegrees="360" : 旋轉(zhuǎn)多少度</span>       

pivotX="50%:旋轉(zhuǎn)中心距離view的左頂點(diǎn)為50%距離,

pivotY="50%: 距離view的上邊緣為50%距離

repeatCount="-1":重復(fù)次數(shù),-1為一直重復(fù)

repeatMode="restart":重復(fù)模式,restart從頭開始重復(fù)

布局文件代碼沒變,依舊是:放一個(gè)控件就行了

</
 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>

你也可以寫成一個(gè)普通的控件都可以實(shí)現(xiàn)旋轉(zhuǎn)

復(fù)制代碼 代碼如下:
<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);
 //動(dòng)畫
  Animation animation = AnimationUtils.loadAnimation(this, R.anim.img_animation);
 LinearInterpolator lin = new LinearInterpolator();//設(shè)置動(dòng)畫勻速運(yùn)動(dòng)
 animation.setInterpolator(lin);
 imageView.startAnimation(animation);
 }

}

 是不是很簡單,運(yùn)行效果如下:錄制的有點(diǎn)問題,實(shí)際上是勻速地。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論