我是Android的新手,我有一个小问题.
我为RotateAnimation找到了以下代码:
xml文件,其中存储了RotateAnimation的所有数据:
<?xml version="1.0" enCoding="utf-8"?><set xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:interpolator="@androID:anim/linear_interpolator"> <rotate androID:fromdegrees="0" androID:todegrees="360" androID:pivotX="50%" androID:pivotY="50%" androID:duration="20000" androID:startOffset="0"/></set>
Java文件:
package com.example.helloword;import androID.app.Activity;import androID.os.Bundle;import androID.support.v4.app.NavUtils;import androID.vIEw.Menu;import androID.vIEw.MenuItem;import androID.vIEw.VIEw;import androID.vIEw.animation.Animation;import androID.vIEw.animation.AnimationUtils;import androID.Widget.button;import androID.Widget.ImageVIEw;public class Rotation_test extends Activity { @OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_rotation_test);// getActionbar().setdisplayHomeAsUpEnabled(true); button buttonRotateCenter = (button) findVIEwByID(R.ID.rotatecenter); final ImageVIEw floatingImage = (ImageVIEw) findVIEwByID(R.ID.floatingimage); final Animation animationRotateCenter = AnimationUtils.loadAnimation( this, R.anim.rotate_center); buttonRotateCenter.setonClickListener(new button.OnClickListener() { public voID onClick(VIEw arg0) { // Todo auto-generated method stub floatingImage.startAnimation(animationRotateCenter); } }); } @OverrIDe public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_rotation_test, menu); return true; } @OverrIDe public boolean onoptionsItemSelected(MenuItem item) { switch (item.getItemID()) { case androID.R.ID.home: NavUtils.navigateUpFromSaMetask(this); return true; } return super.onoptionsItemSelected(item); }}
如何在xml文件中创建这两个值的变量?
androID:fromdegrees="0" androID:todegrees="360"
解决方法:
根据RotateAnimation类参考(http://developer.androID.com/reference/androID/vIEw/animation/RotateAnimation.HTML),此类不提供fromdegrees和todegrees的setter方法.因此,如果需要在代码中设置这些值,则必须在代码中创建RotateAnimation对象,并将fromdegrees和todegrees值传递给构造函数.
RotateAnimation rotateAnimation = new RotateAnimation(fromdegrees, todegrees);
总结 以上是内存溢出为你收集整理的Android-RotateAnimation-fromDegrees toDegrees变量全部内容,希望文章能够帮你解决Android-RotateAnimation-fromDegrees toDegrees变量所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)