Made the button animation spin around its axis in the setOnTouchListener method. And how to make such an animation, so that when you press the button, it shakes? In one program I saw this. I would like to do this in my own way. In this program, the number buttons shake https://play.google.com/store/apps/details?id=com.gokids.bphone1
rotate.xml
<?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:duration="2000" android:fromDegrees="0" android:pivotX="50%" android:pivotY="50%" android:startOffset="0" android:toDegrees="360" /> </set> MainActivity
public class MainActivity extends AppCompatActivity { ImageButton imageButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); imageButton = (ImageButton) findViewById(R.id.imageButton); final Animation animationRotateCenter = AnimationUtils.loadAnimation(this, R.anim.rotate_center); imageButton.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { view.startAnimation(animationRotateCenter); return false; } }); } }