Je développe une application de fond d'écran dans Android et je trouve une bonne façon de définir le fond d'écran déroulant pour mon application. Maintenant, mon code peut définir le fond d'écran à partir de bitmap, mais il a été recadré pour s'adapter à une page et est resté seulement sur une seule page (j'ai 5 pages dans l'écran d'accueil). Cela signifie que le contenu de chaque page peut faire défiler le fond d'écran, mais le fond d'écran ne défilait pas.android Fond d'écran défilable sur le téléphone de l'écran
Je souhaite définir un fond d'écran déroulant. J'ai essayé quelques codes d'internet mais ils n'ont pas aidé. Est-ce que vous avez une idée?
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();
}
}
});
Et je l'utilise à partir de ce code, mais ne fonctionne pas:
//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));