2010-07-16 4 views
0

자바 코드에서 생성 된 사용자 정의보기를 애니메이션하려고하면 효과가 나타나지 않고 애니메이션이 시작되지 않습니다. 이것은 내가하는 방식입니다.애니메이션 사용자 정의보기 클래스

final Animation animation = AnimationUtils.loadAnimation(this, R.anim.animation); 
    final CustomView background = new CustomView(this); 
    background.setBackgroundResource(R.drawable.bg); 
    background.startAnimation(animation); 

CustomView는 CustomView를 확장합니다.

이 코드는 애니메이션을 시작하지 않으며 ImageView에서도 시도했지만 작동하지 않습니다.

애니메이션은 findViewById (id)에서 뷰를 가져올 때만 작동합니다. 해결

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shareInterpolator="false" 
    > 
    <alpha 
     android:fromAlpha="0.0" 
     android:toAlpha="1.0" 
     android:duration="1000" 
     /> 
    <alpha 
     android:fromAlpha="1.0" 
     android:toAlpha="1.0" 
     android:startOffset="1000" 
     android:duration="6000" 
     /> 
    <alpha 
     android:fromAlpha="1.0" 
     android:toAlpha="0.0" 
     android:startOffset="7000" 
     android:duration="1000" 
     /> 
</set> 
+0

애니메이션 용 XML 코드를 게시 할 수 있습니까? –

+0

android : shareInterpolator = "false"속성은 쓸모가 없지만 다른 애니메이션에서이 파일을 복사하여 잘라내는 것을 잊지 않았습니다. – Fisher

답변

0

문제점 : 여기서

애니메이션 코드이다. 실제로 애니메이션이 실행되고있는 것을 알았지 만, onAnimationStart 및 onAnimationEnd에서 super를 호출하는 것을 잊어 버리는 사용자 정의 View 클래스에서 실제 문제가 발생했습니다.

관련 문제