1
주어진 범위 내에서 임의의 크기로 크기가 조정되는 이미지 뷰가 있습니다. 아래의 메서드는 onCreate에서 호출되며 처음 호출 할 때 올바르게 작동합니다. 그러나 onTouchEvent에서 호출 될 때 메서드는 실행되지만 imageView의 크기는 조정하지 않습니다. 거기 motionevent이며, 그 점에 아무 문제가 없다, 그래서 임의의 변수가 생성 될 때화면의 이미지 뷰 크기 조정
public void setInnerCircleSize()
{
widthMultiplier = r.nextInt(75 - 25) + 25;
widthToSet = ((widthScreen/100) * widthMultiplier);
circle.getLayoutParams().height = widthToSet;
circle.getLayoutParams().width = widthToSet;
}
public boolean onTouchEvent(MotionEvent event) {
int eventaction = event.getAction();
switch (eventaction) {
case MotionEvent.ACTION_DOWN:
if(hitCheck == true)
{
hitCheck = false;
setInnerCircleSize();
}
break;
case MotionEvent.ACTION_MOVE:
break;
case MotionEvent.ACTION_UP:
hitCheck = true;
break;
}
}
setInnerCircleSize 미세라고되고있다. onCreate에서 호출 할 때 완벽하게 작동하더라도 두 번째 시간에는 크기가 조정되지 않습니다.
Android 모션 이벤트는 최선의 노력이라는 것을 알아야합니다. 'ACTION_DOWN '마다'ACTION_UP '을 얻을 수있는 것은 아닙니다. – tachyonflux