actually I want to rotate or flip the screen by clicking on button from one activity to another: like this
thanks in advance.
actually I want to rotate or flip the screen by clicking on button from one activity to another: like this
thanks in advance.
You can override the transition between Activities doing this:
Button btn = (Button)findViewById(R.id.myBtn);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(ActualActivity.this,
TargetActivity.class));
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
}
});
Where slide_in_up and slide_out_up are your custom animations, saved in res/anim. Here there are some code examples:
slide_in_up:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="-100%p" android:toYDelta="0" android:duration="300"/>
</set>
slide_out_up:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="0" android:toYDelta="100%p" android:duration="300"/>
</set>
This example will move your activity from top to bottom. You can modify your anim files to obtain different animations.
You can find you answer here: Activity transition in Android
Two options:
Like this:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
getWindow().setWindowAnimations(ANIMATION);
...
}
The link that @abhy provided is the one that we all followed once :)
But its not going to work to change from one activity to another, what i did to achieve that behaviour its to obtain the bitmap of the activity im in and the one that im heading to, make this transition and when its finish make the startactivity overriding the pending transition with no effect.
I dont think that is a great approach and i will love to see if someone has a better idea :)
Regards,