- public class DemoActivity extends Activity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- }
- public void jump(View view){
- Intent intent = new Intent(this,Demo2Activity.class);
- startActivity(intent);
- finish();
- //更改activity组件切换的动画.
- overridePendingTransition(R.anim.trans_in, R.anim.trans_out);
- }
- }
- <?xml version="1.0" encoding="utf-8"?>
- <translate xmlns:android="http://schemas.android.com/apk/res/android"
- android:fromXDelta="100%p"
- android:toXDelta="0"
- android:fromYDelta="0"
- android:toYDelta="0"
- android:duration="500"
- >
- </translate>
- <?xml version="1.0" encoding="utf-8"?>
- <translate xmlns:android="http://schemas.android.com/apk/res/android"
- android:fromXDelta="0"
- android:toXDelta="-100%p"
- android:fromYDelta="0"
- android:toYDelta="0"
- android:duration="500"
- >
- </translate>