나는 시차 스크롤링이있는 라이브 벽지를 만들고 있습니다. 나는 기사를 읽었다 : Parallax effect scrolling of live wallpaper background. 하지만 데스크톱을 바꿀 때 배경이 잘못 움직입니다 (데스크톱을 왼쪽에서 오른쪽으로 변경하면 그림이 오른쪽에서 왼쪽으로 이동 함). 방향을 바꾸는 방법? 코드 스 니펫 : 여기시차 스크롤링으로 안드로이드 라이브 벽지 만들기
public void Init(Bitmap bitmap){
bg = new BitmapFactory().decodeResource(context.getResources(), R.drawable.thunder);
bg = Bitmap.createScaledBitmap(bg, (int)(width*1.4), height, true);
}
float dx = 0.0f;
@Override
public void onOffsetsChanged(float xOffset, float yOffset,
float xStep, float yStep, int xPixels, int yPixels) {
dx = (width - bg.getWidth()) * (1 - xOffset);
}
private void doDraw(Canvas canvas) {
canvas.save();
canvas.translate(dx, 0);
canvas.drawBitmap(bg, 0, 0, null);
canvas.restore();
}
이 작동하지만 어떻게 스크롤 캔버스는 첫 번째와 마지막 홈 페이지에, 배경의 가장자리에 도달의 원인이 될 수 있습니까? –