簡體   English   中英

動畫向右移動后,Android Animation Bug不會讓我單擊

[英]Android Animation Bug wont let me click after animation move to the right

那么,這是我的問題嗎? 我將其放置在滑出的位置,然后將其保持在該位置,然后您應該能夠再次單擊它,然后它將滑回到原始位置。

但是相反,我必須單擊“ FIRST”所在的位置。 即使滑出。 我想在動畫之后制作它,我可以在它滑出的任何位置單擊它。

這是我的代碼

   public void sideBar()
   {

       ImageView sidebar = (ImageView)findViewById(R.id.sidebar);

       if(out == 0)
       {
       mSlideInRight = AnimationUtils.loadAnimation(this, R.anim.slide_in_right);
       mSlideInRight.setFillAfter(true);
       sidebar.startAnimation(mSlideInRight);
       out= 1;
       }
       else if(out == 1)
       {
               mSlideInLeft = AnimationUtils.loadAnimation(this, R.anim.slide_in_left);
               sidebar.startAnimation(mSlideInLeft);
               out=0;
       }

   }

這是您單擊它時的代碼

public void onClick(View v) {
        ImageView sidebar = (ImageView)findViewById(R.id.sidebar);
         ImageView popup = (ImageView)findViewById(R.id.popup);
         ImageView popup2 = (ImageView)findViewById(R.id.popup2);

        switch(v.getId())
        {           
            case R.id.sidebar:
                sideBar();
            break;
        }

    }

動畫只會影響側邊欄ImageView的繪制方式,而不影響其實際位置。 動畫完成后,應將側欄的布局參數更新到所需位置。 如果希望在動畫運行時或動畫完成后更新位置,或者希望在動畫開始時發生位置更改,則在調用startAnimation之后立即更新位置,可以在AnimationListener執行此操作。

mSlideInRight.setAnimationListener(new AnimationListener() {
    @Override
    public void onAnimationStart(Animation anim) {};

    @Override
    public void onAnimationRepeat(Animation anim) {};

    @Override
    public void onAnimationEnd(Animation anim) {
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(...);
        // Set properties of layoutParams here
        sidebar.setLayoutParams(layoutParams);
    };
});

更換RelativeLayout與任何布局您的ImageView是一個孩子。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM