简体   繁体   English

Android动态壁纸onOffsetsChanged

[英]Android Live Wallpaper onOffsetsChanged

I am trying to make a live wallpaper. 我正在尝试制作动态壁纸。 I understand that onOffsetsChanged method is used to get the current position of the screen. 我知道onOffsetsChanged方法用于获取屏幕的当前位置。 I am not able to properly understand how to implement this method to get the livewallpaper or just even a standard wallpaper to move sideways along with the user swipes. 我无法正确理解如何实施此方法来获取动态壁纸,甚至只是标准墙纸与用户滑动一起向侧面移动。 I tries looking through some examples but still i am not clear. 我尝试查看一些示例,但仍然不清楚。 Can someone give me an idea and suggest some good tutorial for a live wallpaper that can move across the screen with user swipes. 有人可以给我一个想法,并为动态壁纸提供一些不错的教程,该场景可以通过用户滑动在屏幕上移动。 Thanks in advance! 提前致谢!

you need to make 你需要做

public float mmPixel;

and then 接着

    public void onOffsetsChanged(float xOffset, float yOffset, float xStep,
            float yStep, int xPixels, int yPixels) {

        mmPixel = xPixels;



    }

and draw your Bitmap like this on Canvas c 然后在Canvas c上绘制这样的位图

    c.drawBitmap(Bitmap bitmap, mmPixel, 0, null);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM