android按钮旋转简单实现

效果:点击按钮后按照设定的角度旋转按钮。

具体实现步骤:

1、添加rotate(旋转)配置文件:



  	android:fromDegrees="0"
  	android:interpolator="@android:anim/accelerate_interpolator"
  	android:pivotX="50%"
  	android:pivotY="50%"
  	android:toDegrees="90" >


2、在Activity中使用Animation
  add_notes_btn.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View v) {
    Animation animation = AnimationUtils.loadAnimation(BookNotesListActivity.this, R.anim.rotate);
    add_notes_btn.setAnimation(animation);
   
    Intent intent = new Intent();
    intent.setClass(getApplicationContext(), AddNoteActivity.class);
    startActivity(intent);
    Toast.makeText(getApplicationContext(), "添加笔记", Toast.LENGTH_SHORT).show();
   }
  });



你可能感兴趣的:(android)