Android 可滚动壁纸

Android 可滚动壁纸,android,wallpaper,Android,Wallpaper,我正在用Android开发一个壁纸应用程序,我正在寻找一种正确的方法为我的应用程序设置可滚动的壁纸。现在,我的代码可以从位图设置墙纸,但它被裁剪为适合一页,只停留在一页上(我在主屏幕上有5页)。这意味着每个页面中的内容都可以在墙纸上滚动,但墙纸没有滚动 我想设置一个可滚动的壁纸。我尝试了一些来自互联网的代码,但没有帮助。 你们知道吗 这是我的密码 WallpaperManager wm = WallpaperManager.getInstance(mActivity.getContext());

我正在用Android开发一个壁纸应用程序,我正在寻找一种正确的方法为我的应用程序设置可滚动的壁纸。现在,我的代码可以从位图设置墙纸,但它被裁剪为适合一页,只停留在一页上(我在主屏幕上有5页)。这意味着每个页面中的内容都可以在墙纸上滚动,但墙纸没有滚动

我想设置一个可滚动的壁纸。我尝试了一些来自互联网的代码,但没有帮助。 你们知道吗

这是我的密码

WallpaperManager wm = WallpaperManager.getInstance(mActivity.getContext());
    try {
        wm.setBitmap(mCropImageView.getCroppedImage());
    } catch (IOException e) {
        e.printStackTrace();
    }

试试这个,它在api>11上对我有效

//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));

试试这个,它在api>11上对我有效

//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));

试试这个,它在api>11上对我有效

//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));

试试这个,它在api>11上对我有效

//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));

我想在我的应用程序中有一张可滚动的壁纸作为背景。(主屏幕更换应用程序)

从我的应用设置壁纸(可以滚动)

但这个问题是谷歌在搜索可滚动墙纸android stackoverflow时的第一篇SO帖子

所以我决定回答这个问题

我用kotlin制作了一个演示应用程序

并且它使用这种方法来滚动壁纸

哪个使用


还有一个我制作的应用程序的演示

我想在我的应用程序中有一个可滚动的壁纸作为背景。(主屏幕更换应用程序)

我的应用设置壁纸(可以滚动)

但这个问题是谷歌在搜索可滚动墙纸android stackoverflow时的第一篇SO帖子

所以我决定回答这个问题

我用kotlin制作了一个演示应用程序

并且它使用这种方法来滚动壁纸

哪个使用


还有一个我制作的应用程序的演示

我想在我的应用程序中有一个可滚动的壁纸作为背景。(主屏幕更换应用程序)

我的应用设置壁纸(可以滚动)

但这个问题是谷歌在搜索可滚动墙纸android stackoverflow时的第一篇SO帖子

所以我决定回答这个问题

我用kotlin制作了一个演示应用程序

并且它使用这种方法来滚动壁纸

哪个使用


还有一个我制作的应用程序的演示

我想在我的应用程序中有一个可滚动的壁纸作为背景。(主屏幕更换应用程序)

我的应用设置壁纸(可以滚动)

但这个问题是谷歌在搜索可滚动墙纸android stackoverflow时的第一篇SO帖子

所以我决定回答这个问题

我用kotlin制作了一个演示应用程序

并且它使用这种方法来滚动壁纸

哪个使用

还有我制作的应用程序的演示