2017-12-14 4 views
1

scrollview에서 10 개의보기를 움직이려고하는데 문제가 있습니다.스크롤 할 때 애니메이션이 작동하지 않습니다.

애니메이션 시작시에만 scrollview 중지 스크롤. scrollview을 스크롤 할 때보기에 애니메이션을 적용하려고합니다.

LayoutInflater inflater = LayoutInflater.from(this); 
     final View view = inflater.inflate(R.layout.view_albumview, null); 
     ImageView imageView = (ImageView) view.findViewById(R.id.imageView); 
     imageView.setBackgroundResource(R.drawable.image_temp01); 

     view.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { 
      @Override 
      public void onScrollChanged() { 

           System.out.println(">>>>>" + view.getX()); 
           if (detectOverLap(view, mainRect)) { 
            ObjectAnimator objectanimator1, objectanimator2; 

            objectanimator1 = ObjectAnimator.ofFloat(view.findViewById(R.id.imageView), "scaleX", 1.0f); 
            objectanimator2 = ObjectAnimator.ofFloat(view.findViewById(R.id.imageView), "scaleY", 1.0f); 
            objectanimator1.start(); 
            objectanimator2.start(); 

            System.out.println("ON INNER"); 
           } 
          } 
         }); 




     return view; 

임의의 위치에있는 ScrollView에 추가 된 전망이다

감사 아 미트 샤르마

+1

공유하시기 바랍니다 코드 –

+0

@ApurvaKolapkar 내가 코드를 업데이트 확인하시기 바랍니다 : 그래서 코드는 다음과 같이해야한다. 애니메이션이 정상적으로 작동하지만 스크롤을 멈추었지만 스크롤 할 때만 나타납니다 –

+0

해결 방법을 찾았습니까? 나는 똑같은 문제가있다. –

답변

0

제로로 ObjectAnimator의 애니메이션 기간을 설정하고 보간을 설정 한 저를 도와 솔루션.

System.out.println(">>>>>" + view.getX()); 
          if (detectOverLap(view, mainRect)) { 
           ObjectAnimator objectanimator1, objectanimator2; 

           objectanimator1 = ObjectAnimator.ofFloat(view.findViewById(R.id.imageView), "scaleX", 1.0f); 
           objectanimator2 = ObjectAnimator.ofFloat(view.findViewById(R.id.imageView), "scaleY", 1.0f); 
           objectanimator1.setInterpolator(new FastOutSlowInInterpolator()); 
           objectanimator2.setInterpolator(new FastOutSlowInInterpolator()); 
           objectanimator1.setDuration(0); 
           objectanimator2.setDuration(0); 
           objectanimator1.start(); 
           objectanimator2.start(); 

           System.out.println("ON INNER"); 
          } 
관련 문제