过渡不起作用 [英] Transition doesn't work

查看:116
本文介绍了过渡不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Fadein.xml文件:

Fadein.xml file:

<?xml version="1.0" encoding="utf-8"?>
    <alpha xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/accelerate_interpolator"
       android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="500" />

Fadeout.xml

Fadeout.xml

<?xml version="1.0" encoding="utf-8"?>
    <alpha xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/accelerate_interpolator"
       android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="500" />

主要业务类开始新的活动时,按钮是pressed:

Main activity class starts new activity when button is pressed:

意图myIntent =新意图(这一点,OtherActivity.class);
        this.startActivity(myIntent);

在OtherActivity类:

In OtherActivity class:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(R.anim.fadein, R.anim.fadeout);
    setContentView(R.layout.view);    
}

它不工作 - 活动不会滑动,它只是打开瞬间。怎么了?

It doesn't work - activities doesn't slide, it just opens instantly. What's wrong?

推荐答案

有可能是两种可能性,如果该活动只是打开瞬间... 1)要么是动画是从设备或模拟器上设置残疾人在其上运行/测试您的应用程序或2)是动画的时间也很少/更少意味着500毫秒,所以可能这就是为什么衰落效应似乎像刚刚开放的效果
但我认为第一点是你的主要问题。

There can be two possibilities if the activity just opens instantly... 1) is either the animations are disabled from settings on the device or emulator on which you running/testing your app or 2) is that the time of animation is also small/less means 500 Milli seconds so may be thats why fading effect is seeming like just opening effect but i think the 1st point is your main problem.

是的,这也是点亚历克斯在他的答复中提到了

Yes That is also the point as Alex Mentioned in his answer that

overridePendingTransition()方法应该叫从同一个活动中startActivity()后,主要是相邻给startActivity()从目标的活动方法,而不是。

overridePendingTransition() method should be called after startActivity() from within the same activity mostly adjacent to startActivity() Method and not from the destination activity.

这篇关于过渡不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆