Android的动态壁纸的重新调整壁纸、动态、Android

2023-09-12 03:40:17 作者:由于网名太個性已被屏蔽

我学习如何做动态壁纸,但我有一个两难我敢肯定,所有谁开始也一样。

I am learning how to make live wallpapers, but I have a dilemma I'm sure all who start off have as well.

有那么多分辨率的屏幕尺寸,我怎么能只让一组作品在code重新调节的所有版本?我知道它已经做了,因为我看到在APK的图像上有很多人,他们得到重新调整。

There is so many resolution screen sizes, how can I just make one set of artwork to be rescaled in code for all versions? I know it's been done as I seen the images in the apk's on a lot of them and they get rescaled.

如果这是不需要任何的定位,这将是很容易只是一个形象,但我的问题是我得重新调整,以适应所有设备的背景图像,我也有适合在一定的x和y位置动画在这样的背景图像以适合的地方,所以它看起来像整个后台进行动画处理,但它只有部分是(我的一帧动态壁纸远离架300图像的方式)。

If it was just one image that did not need any positioning that would be easy, but my problem is I have to get the background image rescaled to fit all devices, I also have animations that fit in a certain x and y position on that background image to fit in place so it looks like the whole background is being animated but only parts of it is (my way of staying away from 300 images of frame by frame live wallpapers).

因此​​,背景图像需要被重新缩放和动画需要被重新缩放,以及以确切的比例作为背景图象,他们需要坐在一个特定的x和y位置。

So the background image needs to be rescaled and the animations need to be rescaled as well to the exact percentage as the background image and they need to sit in a specific x and y position.

任何帮助将是pciated这样我就可以得到这个正在进行的AP $ P $。

Any help would be appreciated so I can get this going.

我累了几件事情,想我会做一个分频器一切例如:INT定标器;那么onSurfaceChanged洁牙机=宽/ 1024; //如果更大的图片是1024,这将使我的比值与海内外合作。然后,扩展从而用scaleBitmap通过由图像的高度和宽度乘以定标器,并且也使用相同的定标器,用于定位例如图像x可以说,在50,使用同样的事情X =缩放器缩放* 50;这应该照顾缩放和定位,只是如何把所有这一切到Java是下一课,因为我是新来的Java,我用了闪光灯和PHP程序,但是这是一个很大的不同,需要一定的时间来适应。接下来的事情是如何平移的宽度,当你从一侧移动屏幕到另一边如何使图像显示的是下一个谜题我已经弄清楚。现在,它只是显示相同的宽度不管是什么,即使是宽度两倍的面表演。如果你有了答案或者其他什么地方,我可以找到在这一个,这将是极大的AP preciated的信息。

I tired a few things, figured I would make a scaler for everything example: int scaler; then in onSurfaceChanged scaler = width /1024; //if the bigger image is 1024. that will give me a ratio to work with everywhere. then scale accordingly using scaleBitmap by multiplying the scaler by the image height and width, and also use the same scaler for positioning example image x lets say is at 50, scale it using the same thing x = scaler * 50; that should take care of scaling and positioning, just how to translate all this into java is the next lesson, since I'm new to java, I used to program for flash and php but this is a lot different, take some getting used to. Next thing is how to pan the width, when you move your screen from side to side how to make the image show is the next puzzle I have figure out. Right now it just shows the same width no matter what even though the width is double what the surface shows. If you got an answer or somewhere I can find out the info on this one that would be greatly appreciated.

推荐答案

嗯,嗯,我能说的是欢迎来到真实的世界。你得到通过onSurfaceChanged传递给您在屏幕尺寸,是的,那是你的工作就是找出如何在此基础上的数据扩展的一切。这就是为什么他们付给我们一掷千金。 :-) 您将要确保你的资源是足够大,以适合你打算支持的最大显示屏,所以你将永远被缩小东西(歪曲比扩大的东西要少得多)。

Well, um, all I can say is "Welcome to the real world." You get your screen dimensions passed to you via onSurfaceChanged, and yes, it is your job to figure out how to scale everything based on this data. That's why they pay us the big bucks. :-) You will want to make sure your resources are large enough to fit the biggest display you intend to support, so you will always be shrinking things (which distorts much less than expanding things).

建议先从这里的最佳实践屏独立:http://developer.android.com/guide/practices/screens_support.html

Suggest starting with "best practices for screen independence" here: http://developer.android.com/guide/practices/screens_support.html

在重新您的要求为更多的帮助更多评论...

Additional comments in re your request for more help...

您不能(必须的)只使用宽度,因为你需要支持多种纵横比扩大你的作品。如果屏幕比例不匹配你的作品,你必须决定是否要扭曲你的作品,留下空格,等等。 在我不知道如何跨preT你的麻烦绕过屏幕尺寸。我们大多数人把我们所有的活动的code一个引擎类中,所以我们的方法可以通过私有变量共享数据。例如,在SDK中立方壁纸,onSurfaceChanged()在drawCube设置mCenterX供以后使用()。我建议开始用类似的,简单的方法。 在处理滚动带您收到通过onOffsetsChanged一些智能和对数据的仔细评估()。特步表示有多少画面你的发射支持。通常XSTEP将0.25,这表明5个画面(即xOffset = 0,0.25,0.5%,0.75,或1),但是它可以是从0到1的任意值; 0.5将表明3个屏幕。 xPixels给你多少发射希望你到你的影像基于你在屏幕上移动的指示;通常,你应该尊重这一点。我的手机上,发射希望一个虚拟的壁纸与物理屏幕的像素的两倍,因此每个滚动应该转向的东西只​​有四分之一的一个一个屏幕的像素。所有这一切,更多的,记录在http://developer.android.com/reference/android/app/WallpaperManager.html 这不是易编码 - 应用程序是比壁纸更容易。 : - ) You cannot (necessarily) scale your artwork just using the width, because you need to support multiple aspect ratios. If the screen proportions do not match your artwork, you must decide if you want to distort your artwork, leave blank spaces, etc. I'm not sure how to interpret your trouble passing around the screen dimensions. Most of us put all of our active code within a single engine class, so our methods can share data via private variables. For example, in the Cube wallpaper in the SDK, onSurfaceChanged() sets mCenterX for later use in drawCube(). I suggest beginning with a similar, simple approach. Handling scrolling takes some "intelligence" and a careful assessment of the data you receive via onOffsetsChanged(). xStep indicates how many screens your launcher supports. Normally xStep will be 0.25, indicating 5 screens (i.e. xOffset = 0, 0.25, 0.5, 0.75, or 1) but it can be any value from 0 to 1; 0.5 would indicate 3 screens. xPixels gives you an indication of how much the launcher "wants" you to shift your imagery based on the screen you're on; normally you should respect this. On my phone, the launcher "desires" a virtual wallpaper with twice the pixels of the physical screen, so each scroll is supposed to shift things only one quarter of one screen's pixels. All this, and more, is documented in http://developer.android.com/reference/android/app/WallpaperManager.html This is not "easy" coding--apps are easier than wallpaper. :-)

祝你好运...乔治

P.S。我会扔在一件事:某处沿线,你可能想获取所需的发射壁纸的所需的最小宽度,这样你就可以明确地理解虚拟化隐含在xPixels。例如,在我的引擎构造,我有

P.S. I'll throw in one more thing: somewhere along the line you might want to retrieve the "desired minimum width" of the wallpaper desired by the launcher, so you can explicitly understand the virtualization implicit in xPixels. For example, in my engine constructor, I have

mContext = getApplicationContext();
mWM = WallpaperManager.getInstance(mContext);
mDW = mWM.getDesiredMinimumWidth();

我的设备具有320像素的宽度;我得到MDW = 640;因为我从滚动屏显示中,每次xPixels变化; 80 ......因为4卷轴(横跨五个屏幕)应该加倍透露作品的数量(这种效应被称为视差滚动)。最右边的部分有xPixels等于0; (五)部分中心拥有xPixels = -160等。

My device has 320 pixel width; I get mDW = 640; as I scroll from screen to screen, xPixels changes by 80 each time...because four scrolls (across five screens) is supposed to double the amount of revealed artwork (this effect is called "parallax scrolling"). The rightmost section has xPixels equals 0; the center (of five) sections has xPixels = -160, etc.