我正在尝试设置我的动态壁纸的背景,以便完美地适合屏幕。当前壁纸尺寸为 1024x1024,但只有部分图像出现在我的 HTC Desire 屏幕上(尺寸为 480 x 800)。此外,当我尝试设置小于 480x800 的图像时,图像不会拉伸以适合整个屏幕。
有什么方法可以实现这一点,使墙纸至少在高度上完美贴合,而与屏幕尺寸无关?
这是我的代码供您参考-
private static final int CAMERA_WIDTH = 480;
private static final int CAMERA_HEIGHT = 720;
@Override
public EngineOptions onCreateEngineOptions() {
final Camera camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
return new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera);
}
@Override
public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) throws Exception {
.
.
this.mBitmapBackgroundAtlas1 = new BitmapTextureAtlas(this.getTextureManager(), 1024, 1024);
this.mFaceBackgroundRegion1 = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mBitmapBackgroundAtlas1, this, "bg1.jpg", 0, 0);
this.mBitmapBackgroundAtlas1.load();
.
.
}
@Override
public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws Exception {
this.mEngine.registerUpdateHandler(new FPSLogger());
.
.
mScene.setBackground(new SpriteBackground(new Sprite(0, 0, mFaceBackgroundRegion1, this.getVertexBufferObjectManager())));
.
.
}