1

ホーム画面にスクロール可能な壁紙を設定したいのですが、私の壁紙は自動的に中央がクロップされます。私が使用している画像の比率は「3:2 / 16:9」であるため、ホームスクリーンの複数のページに均一に広げたいと考えています。

私は現在使用しています:

wallpaperManager.suggestDesiredDimensions(width, height);
wallPaperBitmap = BitmapFactory.
                        decodeStream(url);

wallpaperManager.setBitmap(wallPaperBitmap);

`

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21"/>
4

1 に答える 1

-2

androidhive.com の助けを借りて

//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 works
wallpaperManager.setBitmap(Bitmap.createScaledBitmap(wallPaperBitmap, width, height, true));
于 2015-02-03T19:54:31.837 に答える