- 补间动画 介绍: https://www.jianshu.com/p/733532041f46
alpha 属性 动画透明度 Rorate属性 旋转 Scale属性 缩放 Translate 属性 创建anim包 创建rotate.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360"
android:fromDegrees="0"
android:duration="2000">
</rotate>
translate.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:fromXDelta="0"
android:toXDelta="200"
android:fromYDelta="0"
android:toYDelta="200">
</translate>
布局里添加一个按钮,点击按钮实现用Intent跳转 然后调用overridePendingTransition 方法传参数 两个xml布局
public class MainActivity extends AppCompatActivity {
private Button btn1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}
private void initView() {
btn1 = (Button) findViewById(R.id.btn1);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, Main2Activity.class);
startActivity(intent);
overridePendingTransition(R.anim.rotate,R.anim.translate);
}
});
}
}
|