Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not Working!! #49

Open
s1mar opened this issue Jan 31, 2017 · 11 comments
Open

Not Working!! #49

s1mar opened this issue Jan 31, 2017 · 11 comments

Comments

@s1mar
Copy link

s1mar commented Jan 31, 2017

I'm doing this,it is not working for me,any pointers guys

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setEnterTransition();
        setExitTransition();
      
    }

    @TargetApi(21)
    private void setEnterTransition(){

        Fade fade_transition = new Fade();
        fade_transition.setDuration(1000);
        getWindow().setEnterTransition(fade_transition);
    }

    @TargetApi(21)
    private void setExitTransition(){

        Slide slide_transition = new Slide();
        slide_transition.setDuration(1000);
        getWindow().setExitTransition(slide_transition);
    }
@lgvalle
Copy link
Owner

lgvalle commented Feb 11, 2017

Can you please provide more info? What is happening? What do you expect to happen?

@MarijanGazica
Copy link

My guess is that you are missing this in your styles.xml

<item name="android:windowContentTransitions">true</item

@s1mar
Copy link
Author

s1mar commented Feb 21, 2017

@MarijanGazica I was setting the basic slide and fade transitions programmatically(no xml),but they aren't working,I see no effect

@MarijanGazica
Copy link

@s1mar even though you did it programmatically, you still, from my experience, need to add that flag. Also, which version of Android is running on your test device(s)?

@iamtodor
Copy link

iamtodor commented Mar 5, 2017

@lgvalle @MarijanGazica the same happened with me. I have set animation via program way, setup flag <item name="android:windowContentTransitions">true</item and nothing. Either nexus 5x 7.0 or emulator 6p 6.0

@Davids89
Copy link

Davids89 commented Apr 19, 2017

Hello @s1mar I think you have to start the activity with this code

ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this);

startActivity(intent, options.toBundle());

@RichyHBM
Copy link

@Davids89 Hey, I'm having the same issues, I got the enter animation to work by adding the startActivity parameter but my exit transitions still don't work. Do you know if there is anything else necessary?

@pcg92
Copy link

pcg92 commented Jun 1, 2017

@Davids89 its working with this solution, but on my back press my activity is full grey, without UI

@s1mar
Copy link
Author

s1mar commented Jun 18, 2017

@Davids89
` @OverRide
protected void onCreate(@nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
setupWindowAnimations();
}

private void setupWindowAnimations() {
    Slide slide =(Slide) TransitionInflater.from(this).inflateTransition(R.transition.activity_slide);
    getWindow().setExitTransition(slide);
}

@Override
protected void onStart() {
    super.onStart();
    ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(Splash.this);
    Intent intent = new Intent(this,Splash2.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    startActivity(intent,options.toBundle());
}`

still not working.

@pcegarra try adding the FLAG_ACTIVITY_NO_HISTORY, this will prevent your activity from going into the back stack,hope it works for you

@s1mar
Copy link
Author

s1mar commented Jun 19, 2017

I've followed every instruction available on the internet and still couldn't get it to work. What I've observed is that on a cold start,you just cant see the enter transition of our launcher activity.Also, ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(Splash.this); Intent intent = new Intent(this,Splash2.class); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); startActivity(intent,options.toBundle());

if you use a transition activity code,android simply seems to skip through the transition effects and launch the next activity. I believe there is something that you're forgetting to mention or tell us @lgvalle

@daleige
Copy link

daleige commented Mar 31, 2020

I'm having the same issues,setExitTransition(Slide)not working,but the enter return and reenter is working

public class OneActivity extends AppCompatActivity implements View.OnClickListener {
    private Button mBack;
    private Button mNext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_one);
        setupWindowAnimations();
        mBack = findViewById(R.id.btn_back);
        mNext = findViewById(R.id.btn_next);
        mBack.setOnClickListener(this);
        mNext.setOnClickListener(this);
    }

    private void setupWindowAnimations() {
        Slide enter = new Slide();
        enter.setDuration(DURATION);
        enter.setSlideEdge(Gravity.RIGHT);
        enter.setInterpolator(new DecelerateInterpolator());

        Slide exit = new Slide();
        exit.setDuration(DURATION);
        exit.setSlideEdge(Gravity.LEFT);
        exit.setInterpolator(new DecelerateInterpolator());

        Slide reenter = new Slide();
        reenter.setSlideEdge(Gravity.LEFT);
        reenter.setDuration(DURATION);
        reenter.setInterpolator(new DecelerateInterpolator());

        Slide returnT = new Slide();
        returnT.setDuration(DURATION);
        returnT.setSlideEdge(Gravity.RIGHT);
        returnT.setInterpolator(new DecelerateInterpolator());

        getWindow().setReenterTransition(reenter);
        getWindow().setEnterTransition(enter);
        getWindow().setReturnTransition(returnT);
        getWindow().setExitTransition(exit);
        getWindow().setAllowEnterTransitionOverlap(true);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_back:
                finishAfterTransition();
                break;
            case R.id.btn_next:
                Intent i = new Intent(this, TowActivity.class);
                startActivity(i, ActivityOptionsCompat.makeSceneTransitionAnimation(this).toBundle());
                break;
            default:

        }
    }
}

please help me,thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants