我要求当我调用下一个活动时,我想要进行布局转换。 当前布局应向左和向下移动,否则新视图应像HDFC移动银行应用程序https://play.google.com/store/apps/details?id=com.snapwork.hdfc&feature=search_result#?t=W251bGwsMSwyLDEsImNvbS5zbmFwd29yay5oZGZjIl0一样向右移动..
答案 0 :(得分:2)
使用overridePendingTransition在调用finish或startActivity之后/之前更改转换。
答案 1 :(得分:2)
<强> RES /动画/ slide_in_left.xml 强>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="-100%p" android:toXDelta="0" android:duration="400" />
</set>
<强> RES /动画/ slide_out_left.xml 强>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0" android:toXDelta="-100%p" android:duration="400" />
</set>
<强> MainActivity.java 强>
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(getApplicationContext(), Activity2.class));
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left);
}
});
}
<强> Activity2.java 强>
@Override
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left);
}