2017-05-02 7 views
1

플로팅 버튼에 풀 로테이션 애니메이션을주고 싶습니다. 코드가 있지만 애니메이션을 반으로 움직이는 것과 같습니다. 나는 부동 단추를 한 위치에서 회전시키고 싶습니다. 그리고 그것은 시작된 위치 (전체 회전)와 어떻게 끝나야합니까? 여기 플로팅 버튼의 애니메이션을 구현하고 싶습니다.

내가 어떤 사람은 고해상도의 값 또는 코드

final OvershootInterpolator interpolator = new OvershootInterpolator(); 
      ViewCompat.animate(fab). 
        rotation(170f). 
        withLayer(). 
        setDuration(1000). 
        setInterpolator(interpolator). 
        start(); 

답변

1

만들기 rotate.xml을 수정하려면, 내 코드/ANIM : 코드에서 다음

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"> 
    <rotate 

     android:fromDegrees="0" 
     android:toDegrees="360" 
     android:pivotX="50%" 
     android:pivotY="50%" 
     android:repeatCount="0" 
     android:duration="1000" /> 

</set> 

:

FloatingActionButton mFloatingButton = view.findViewById(R.id.myFloatingButton); 

     Animation mAnimation = AnimationUtils.loadAnimation(this, R.anim.rotate); 

     mFloatingButton.startAnimation(mAnimation); 
+0

심볼을 해석 할 수 없음 '컨텍스트 –

+1

활동에있는 경우 "컨텍스트"대신 "this"를 사용하십시오. –