顺时针旋转动画
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:fromDegrees="0"
android:toDegrees="360"
android:duration="900"
></rotate>
</set>
左滑动动画
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="-0%"
android:toXDelta="0%"
android:duration="600">
</translate>
</set>
右滑动动画
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="0%"
android:toXDelta="100%"
android:duration="600">
</translate>
</set>
Activity 切换时使用动画
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_clear: {
Log.i("click,trigger","设置焦点");
username.setText("");
password.setText("");
username.requestFocus();
break;
}
case R.id.login: {
showToast("登录成功", Toast.LENGTH_LONG);
jumpPage(ContentActivity.class);
overridePendingTransition(R.anim.rotate_simple,0);
break;
}
}
fragment 切换时候使用动画
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/my_navgation"
app:startDestination="@id/homeFragment2">
<fragment
android:id="@+id/homeFragment2"
android:name="com.example.myapplication.fragment.HomeFragment"
android:label="fragment_home"
tools:layout="@layout/fragment_home">
<action
android:id="@+id/action_homeFragment2_to_detailFragment2"
app:destination="@id/detailFragment2"
app:enterAnim="@anim/slide_from_left"
app:exitAnim="@anim/slide_from_right"/>
</fragment>
<fragment
android:id="@+id/detailFragment2"
android:name="com.example.myapplication.fragment.DetailFragment"
android:label="fragment_detail"
tools:layout="@layout/fragment_detail"/>
</navigation>