-
[Android] addview로 붙인 view의 제자리 rotate animationAndroid 2018. 3. 27. 17:24
rotate animation은 아래와 같이 하면 잘 돌아감
image = new ImageView(MyClass.this); layout.addView(image, width, height); image.setX(206); image.setY(206);
but, addView로 붙인 경우는 parent View의 (0,0) 축을 기준으로 rotation이 되어야 하므로 아래처럼 해야 함
//돌아가는 애니메이션 생성 final RotateAnimation rotateAnimation = new RotateAnimation(0, 3600, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation.setDuration(900L) FrameLayout.LayoutParams layoutParam = new FrameLayout.LayoutParams(100, 100); layoutParam.gravity= Gravity.CENTER; layoutParam.leftMargin = width; layoutParam.topMargin = height; dices[diceCount - 1] = dice; content_area.addView(dice, layoutParam); // 적용 dices[i].startAnimation(rotateAnimation);
'Android' 카테고리의 다른 글
[Android] Keyboard doesn't show up automatically when enter to activity in Android Pie (2) 2019.03.12 [Android] 앱 사이즈 줄이기 shrinkResource Error - Removing unused resources requires unused code shrinking to be turned on. (0) 2018.12.04 [Android] AndroidManifest.xml의 <supports-screens> 속성 (0) 2018.03.20 Fabric 적용법 (0) 2018.03.06 MacOS Android Studio 단축키 (0) 2018.03.06