이 기사에서는 Java가 프레임 애니메이션을 구현할 수있는 예제 코드를 설명합니다. 다음과 같이 참조에 대해 공유하십시오.
1. 복제 다이어그램
2. 프레임 애니메이션에 대한 간단한 코드
Private ImageView bganimview; 개인 애니메이션 흡기 가능 조정 촬영 가능; // manimationDrawable 초기화 = 새 AnimationDrawable (); bganimview = new ImageView (McOntext); bganimview.setbackground drawable (getAnimationDrawable (ManimationDrawable)); params = new framelayout.layoutparams (viewgroup.layoutparams.wrap_content, viewgroup.layoutparams.wrap_content); params.topmargin = util.div (176 + 58); params.gravity = gravity.center_horizontal; addView (bganimview, params); 개인 애니메이션 촬영 가능한 getAnimationDrawable (animationDrawable ManimationDrawable) {int duration = 50; ManimationDrawable.addframe (mcontext.getResources (). getDrawable (r.drawable.loading1), 지속 시간); ManimationDrawable.addframe (McOntext.getResources (). getDrawable (r.drawable.loading2), 시간); ManimationDrawable.addframe (McOntext.getResources (). getDrawable (r.drawable.loading3), 지속 시간); ManimationDrawable.setonShot (false); 반환 ManimationDrawable; } // 애니메이션 시작 public void animloadingstart () {this.setvisability (view.visible); if (ManimationDrawable! = null) {ManimationDrawable.start (); }} // Anime End public void animloadingend () {if (ManimationDrawable! = null) {ManimationDrawable.stop (); } 3. 확장 :
// x 축 변환 public void animy (int y, int nexty, int duration) {linearinterpolator ll = new linearinterpolator (); // constant-speed objectAnimator = objectanimator.offloat (YourView, "TranslationY", 0, 300); // 300 음수 인 경우 위쪽으로 번역되어 있습니다. Animator.SetInterPolator (LL); animator.start (); } // y 축 변환 public void Animx (int x, int nextx, int duration) {linearinterpolator ll = new linearinterpolator (); Objectanimator Animator = Objectanimator.offloat (YourView, "TranslationX", X, NextX); Animator.SetDuration (지속 시간); Animator.SetInterPolator (LL); animator.start (); } // Lonear 압축 0.5 회 선형 린터 폴라 LL = 새로운 linearinterpolator (); // 정적 scaleanimation scaleanimation = new scaleanimation (1, 1, 1, 0.5f); // (0,0) scaleanimation.setduration (500); scaleanimation.setinterpolator (ll); scaleanimation.setfillafter (true); ChartView.Startanimation (scaleanimation); // 수평 압축 0.5 배 선형 interpolator ll = 새로운 linearinterpolator (); scaleanimation scaleanimation = 새로운 scaleanimation (1, 0.5f, 1, 1); // (0,0) scaleanimation.setduration (500)의 기본값; scaleanimation.setinterpolator (ll); scaleanimation.setfillafter (true); ChartView.Startanimation (scaleanimation);자료의 다운로드 주소를 열려면 클릭하십시오
위는이 기사의 전체 내용입니다. 이 기사의 내용에 모든 사람의 연구 나 작업에 대한 특정 참조 가치가 있기를 바랍니다. 궁금한 점이 있으면 의사 소통을 위해 메시지를 남길 수 있습니다. Wulin.com을 지원 해주셔서 감사합니다.