int imgSize = 30;
final ShapeDrawable redDot = new ShapeDrawable(new OvalShape());
redDot.getPaint().setColor(Color.RED);
redDot.setIntrinsicHeight(imgSize);
redDot.setIntrinsicWidth(imgSize);
final Bitmap bitmap = Bitmap.createBitmap(imgSize, imgSize, Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(bitmap);
redDot.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
redDot.draw(canvas);
ImageView imgAnimArea = new ImageView(getActivity());
imgAnimArea.setImageBitmap(bitmap);
imgAnimArea.setScaleType(ImageView.ScaleType.CENTER);
animationsView.addView(imgAnimArea);
final AnimationSet animSetRedDot = new AnimationSet(true);
// animSetRedDot.setFillAfter(true);
// animSetRedDot.setFillEnabled(true);
Animation aniRepeatFadeIn = null;
Animation aniRepatFadeOut = null;
// fade out
aniRepatFadeOut = new AlphaAnimation(1, 0);
aniRepatFadeOut.setStartOffset(3000);
aniRepatFadeOut.setDuration(300);
animSetRedDot.addAnimation(aniRepatFadeOut);
// fade out animation works only if remove this part
aniRepeatFadeIn = new AlphaAnimation(0, 1);
aniRepeatFadeIn.setStartOffset(6000);
aniRepeatFadeIn.setDuration(300);
animSetRedDot.addAnimation(aniRepeatFadeIn);
imgAnimArea.startAnimation(animSetRedDot);
간단한 코드 (적어도 애니메이션 부분)는 매우 이상한 동작을합니다. 기본적으로 애니메이션 전에 모양 (작은 빨간색 원)을 비트 맵으로 변환하여 animationsView
(FrameLayout)에 ImageView
의 소스 (imgAnimArea
)로 추가합니다.
빨간 점이 점점 희미 해지지만 뒤쪽에는 나타나지 않습니다. 페이드 아웃 후에도 페이드가 사라지더라도 페이드 부분이 제거 된 경우에만 작동합니다. 나는 0 대신에 .5f로 페이드 아웃을 설정하려고 노력했다.이 경우 그것은 시야의 절반을 사라지게한다.
또한 animationsView
애니메이션을 시도했지만 결과가 동일합니다 - 일부만 페이드 아웃하면 부분이 사라지고 부분적으로 페이드가 추가되면 전체 애니메이션이 전혀 작동하지 않습니다.
전혀 애니메이션이없는 모양을 볼 수 있습니다. 어쨌든 애니메이션이 끝난 후에도 볼 수있었습니다. FillAfter를 활성화 또는 비활성화해도 아무런 효과가 없습니다.
그래서 여기서 질문이 뭐니? 왜 애니메이션의 페이드가 작동하지 않습니까? 애니메이션이 사라지면 전체 애니메이션이 작동하지 않는 이유는 무엇입니까?애니메이션은 페이드 아웃하지만 애니메이션은 페이드 인하지 않습니다.
하나 하나도 바람직하다
코드가 여기에 좋아 보인다입니다. 페이드 아웃이 완료된 후 3 초 후에 페이드 인 애니메이션을 시작해야합니다. 더 많은 코드를 첨부 할 수 있습니까? 이 코드는 어디에서 호출 되었습니까? –
실제로 아무것도 표시 할 수 없습니다. 위의 코드는 메서드의 99 %가 호출됩니다. 유일한 첫 번째 코드 행과 첫 번째 코드 행이 누락되었습니다. 'animationsViewWrapper.setVisibility (View.VISIBLE);' – Stan