1

So i'm trying to do 2 animations simultaneously, one to move a textview, and one to show a linearlayout (also 2 animations to hide them). I have another animation working as intended to show/hide a seperate layout. When i execute showing the view with 2 animations, it works once, it hides fine, but then doesn't work again. Then when i show the other view, it plays all 3 animations (not intended). I can't figure out why this is happening? When i try to show the 2 animations it does nothing, but then when i try the other show view its like it was added to a queue and it shows all 3.

My code for initiating the two animations:

        LinearLayout layoutMsgs = (LinearLayout)findViewById(R.id.layoutMsgs);
        Animation anim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.msgs_show);
        anim.setAnimationListener(new AnimListener(layoutMsgs, View.VISIBLE)); // sets visibility on animation end
        layoutMsgs.startAnimation(anim);

        TextView tvMsgs = (TextView)findViewById(R.id.tvMsgs);
        Animation tvAnim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.tvmsgs_show);
        tvMsgs.startAnimation(tvAnim);

My code for hiding the two animations:

    LinearLayout layoutMsgs = (LinearLayout)findViewById(R.id.layoutMsgs);
    Animation animLayout = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.msgs_hide);
    animLayout.setAnimationListener(new AnimListener(layoutMsgs, View.INVISIBLE));
    layoutMsgs.startAnimation(animLayout);

    TextView tvMsgs = (TextView)findViewById(R.id.tvMsgs);
    Animation animMsgs = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.tvmsgs_hide);

    tvMsgs.startAnimation(animMsgs);

Then this is the other animation that is working fine, it's only one animation, no textView, just a layout

        LinearLayout pokeLayout = (LinearLayout)findViewById(R.id.layoutPokes);
        Animation anim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.poke_show);
        anim.setAnimationListener(new AnimListener(pokeLayout, View.VISIBLE));
        pokeLayout.startAnimation(anim);

So how can i fix this? Sorry if my explanation is bad i'm finding it difficult to explain all the details, please ask for any missing information.

1 Answers1

0

solved by using solution in this post Android: Using ObjectAnimator to translate a View with fractional values of the View's dimension

wasn't pretty as I had to create seperate translate X and translate Y res files for each view I need to move.. ended up with like 15 anim files. Would still like to know if theres a better solution

Community
  • 1
  • 1