0
私はAndroidで壁紙アプリケーションを開発しており、私のアプリのスクロール可能な壁紙を設定する正しい方法を見つけることができます。さて、私のコードは、ビットマップから壁紙を設定することができますが、それは1ページに収まるように切り取られ、ちょうど1ページ(私はホーム画面で5ページを持っている)にとどまった。つまり、各ページのコンテンツは壁紙をスクロールできますが、壁紙はスクロールできませんでした。アンドロイド画面の電話でプログラム可能にスクロール可能な壁紙
スクロール可能な壁紙を設定したいと思います。私はインターネットからいくつかのコードを試しましたが、彼らは助けませんでした。皆さんは何か考えていますか?
setImage_Wallpaper.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
File file = imageLoader.getDiscCache().get(urldisplay);
Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
WallpaperManager myWallpaperManager
= WallpaperManager.getInstance(mContext);
try {
myWallpaperManager.setBitmap(bitmap);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
そして私は、このコードから使用しますが、動作しません:
//get screen height
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
screenHeight = size.y;
wallPaperBitmap= ... //your bitmap resource
//adjust the aspect ratio of the Image
//this is the main part
int width = wallPaperBitmap.getWidth();
width = (width * screenHeight)/wallPaperBitmap.getHeight();
//set the wallpaper
//this may not be the most efficent way but it worked for me
wallpaperManager.setBitmap(Bitmap.createScaledBitmap(wallPaperBitmap, width, height, true));