我想縮放壁紙設置的位圖但沒有影響:我有這樣的代碼,並在原文件夾和陣列中的所有.jpg文件,代碼:位圖到壁紙調整大小縮放設置壁紙
baton3.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
InputStream tapeta = getResources().openRawResource(textureArrayWin[n]);
Bitmap bitmap = BitmapFactory.decodeStream(tapeta);
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
int oldwidth= bitmap.getWidth();
int oldheight= bitmap.getHeight();
float skalaszerokosci = ((float) oldwidth)/width;
float skalawysokosci = ((float)oldheight)/height;
Matrix macierz = new Matrix();
macierz.postScale(skalaszerokosci, skalawysokosci);
Bitmap zmieniona = Bitmap.createBitmap(bitmap, 0, 0,
width, height, macierz, true);
try
{
getApplicationContext().setWallpaper(zmieniona);
}
catch(IOException e)
{
e.printStackTrace();
}
}
});
順便說一句。壁紙太大,縮放:| – ramzixp
您是否嘗試過'createScaledBitmap()'而不是? – DeeV
是的,嘗試過......同樣的效果,看起來setWallpaper是seting自己的決議:| – ramzixp