0
앱에 스프라이트 애니메이션이 있고 표준 전화 크기 화면에서는 정상적으로 작동하지만 태블릿에 올릴 때마다 애니메이션이 흐트러져서 전혀 보이지 않습니다. 나는 그것이 이미지의 높이와 너비와 관련이 있다고 생각합니다. 나는 그들을 dp 및 sp로 설정하려고 시도했지만 여전히 타블렛에서 렌더링되지 않습니다.안드로이드 태블릿에서 스프라이트 이미지 렌더링이 잘못되었습니다.
여기에 여기에 내가 그것을
public void run() {
mHandler.removeCallbacks(myTimerTask);
if (mCurrScreen == WAITING_SCREEN) {
mHandler.postDelayed(myTimerTask, 300);
}
anim.update();
anim.invalidate();
}
를 진행가
anim = (AndroidAnimation) findViewById(R.id.animation);
anim.init(BitmapFactory.decodeResource(getResources(), R.drawable.connecting_sprite), 300, 170, 3);
mHandler.removeCallbacks(myTimerTask);
mHandler.postDelayed(myTimerTask, 300);
내 핸들러를 초기화 어디 내 애니메이션 코드
public class AndroidAnimation extends View{
private Bitmap mAnimation;
private Rect mSRectangle;
private int mNoOfFrames;
private int mCurrentFrame;
private int mSpriteHeight;
private int mSpriteWidth;
public AndroidAnimation(Context context, AttributeSet aSet) {
super(context, aSet);
mSRectangle = new Rect(0,0,0,0);
mCurrentFrame = 0;
}
public void init(Bitmap theBitmap, int Height, int Width, int theFrameCount) {
mAnimation = theBitmap;
mSpriteHeight = Height;
mSpriteWidth = Width;
mSRectangle.top = 0;
mSRectangle.bottom = mSpriteHeight;
mSRectangle.left = 0;
mSRectangle.right = mSpriteWidth;
mNoOfFrames = theFrameCount;
mCurrentFrame = 0;
}
public void update() {
mCurrentFrame++;
mCurrentFrame %= mNoOfFrames;
mSRectangle.left = mCurrentFrame * mSpriteWidth;
mSRectangle.right = mSRectangle.left + mSpriteWidth;
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
Rect dest = new Rect(0, 0, mSpriteWidth, mSpriteHeight);
canvas.drawBitmap(mAnimation, mSRectangle, dest, null);
}
}
의 내 애니메이션 XML
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingLeft="100dp" >
<view
android:id="@+id/animation"
android:layout_width="180dp"
android:layout_height="220dp"
class="com.scale.AndroidAnimation" />
</LinearLayout>
입니다
미리 감사드립니다!