주위에 해결책을 찾을 수없는 이상한 행동이 있습니다 ... 내 스마트 폰 (Android 4.1)의 레벨 10 에뮬레이터 API 레벨 10에서만 정상적으로 작동합니다.Android : AnimationDrawable 내 이미지 집어 넣기
동적 인 애니메이션을 작성하여 애니메이션의 프레임으로 10 개의 임의 프레임이 선택되고 50ms의 지속 시간이 표시됩니다.
버튼을 누르면 애니메이션이 실행되지만 높이가 0으로 압착됩니다. (애니메이션 주사위에서 여전히 색상이 보일 수 있습니다.) 레이아웃도 엉망이됩니다. 내 휴대 전화에서는 이런 일이 발생하지 않습니다.
public void RollDice(View view) {
int id=-1;
AnimationDrawable diceAnimation = new AnimationDrawable();
//create 10 random frames from dice1.jpg to dice6.jpg into diceAnimation
for(int j=0;j<10;j++){
id=getResources().getIdentifier("dice"+String.valueOf(rng.nextInt(6)+1), "drawable", getPackageName());
diceAnimation.addFrame(getResources().getDrawable(id), 50);
}
//assigning and starting animation
diceAnimation.setOneShot(true);
dice.setImageDrawable(diceAnimation);
diceAnimation.start();
}
상기 XML 부분 : 여기서
는 자바 코드의 부분 인
<ImageView
android:id="@+id/Dice1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/diceimage"
android:src="@drawable/dice1" />
버튼은 온 클릭 RollDice()를 호출한다. 내가 이미지 뷰에 하드 코딩 경우
최종 발언으로, 안드로이드 말 : layout_height = "100dp"은 다음 주사위 애니메이션 동안 보여 주지만, 재미있는 모양으로 늘어나는 것과 것입니다 ...
내가 시도 대부분의 스케일링 방법, 행운과 adjustviewbound 등 ...
어떤 도움이 필요합니까? :( – Ivan