我正在使用Apis的幻灯片来展示两个活动之间的滑入和滑出。 但是当我从一个活动跳到另一个活动时,出现一个黑屏。
滑左
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator" > <translate android:duration="300" android:fromXDelta="100%p" android:toXDelta="0" /> </set>滑右对齐
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator" > <translate android:duration="300" android:fromXDelta="-100%p" android:toXDelta="0" /> </set>从一个活动跳转到另一个活动: -
Button button1 = (Button) findViewById(R.id.Button01); button1.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { startActivity(new Intent(getApplicationContext(), SecondView.class)); overridePendingTransition(R.anim.slide_left, R.anim.slide_right);});
为什么这个黑屏出现在两个活动之间。
I am using Apis 's deme for slide-in and slide-out between two activity. But when I jump from one activity to another a black screen is appearing.
Slide-Left-
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator" > <translate android:duration="300" android:fromXDelta="100%p" android:toXDelta="0" /> </set>Slide-Right-
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator" > <translate android:duration="300" android:fromXDelta="-100%p" android:toXDelta="0" /> </set>To Jump from one activity to another:-
Button button1 = (Button) findViewById(R.id.Button01); button1.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { startActivity(new Intent(getApplicationContext(), SecondView.class)); overridePendingTransition(R.anim.slide_left, R.anim.slide_right);});
Why is this black screen is appearing between two activity.
最满意答案
你的第一个xml应该是这样的:
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator" > <translate android:duration="300" android:fromXDelta="0" android:toXDelta="100%p" /> </set>fromXDelta是在动画开始处应用的水平转换。 将它设置为“100%p”会使动画开始时第一个活动刚刚移出屏幕,因此出现空白屏幕。
对函数overridePendingTransition(int, int)的调用应该是这样的:
overridePendingTransition(R.anim.slide_right, R.anim.slide_left);第一个参数确定第二个活动使用的过渡动画。 另外,这两个动画可以更正确地命名为slide_out_to_right和slide_in_from_left,因为实际上它们都向右滑动。
Your first xml should be like:
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator" > <translate android:duration="300" android:fromXDelta="0" android:toXDelta="100%p" /> </set>fromXDelta is the horizontal translation applied at the beginning of the animation. Setting it to "100%p" makes the first activity shift just right out of the screen at the inception of the animation, hence the blank screen.
The call to the function overridePendingTransition(int, int) should be like this:
overridePendingTransition(R.anim.slide_right, R.anim.slide_left);The first argument determines the transition animation used by the second activity. Also the two animations can be more properly named as slide_out_to_right and slide_in_from_left, since in fact they all slide to the right.
更多推荐
android,活动,activity,电脑培训,计算机培训,IT培训"/> <meta name="descripti
发布评论