-1

我有一个要求,当我调用下一个活动时,我想做布局的转换。当前布局应该向左和下移动,或者新视图应该像 HDFC 移动银行应用程序一样向右移动https://play.google.com/store/apps/details?id=com.snapwork.hdfc&feature=search_result# ?t=W251bGwsMSwyLDEsImNvbS5zbmFwd29yay5oZGZjIl0 ..

4

2 回答 2

2

使用 overridePendingTransition 在调用完成或 startActivity 之后/之前更改转换。

于 2013-05-25T05:20:34.313 回答
2

res/anim/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/anim/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);
    }
于 2013-05-25T06:36:31.707 回答