android - Positioning Bitmaps on different screens -


I know there are many other threads about it. I have not been using any of them for the past two days and now it is driving me crazy, basically I have a spritesheet, which I load in a bitmap, separating the frame, on them Scaling and then loads them in a list for animation. Scaling up LDPI to XHDPI also looks good, animation also does.

But there is one more thing that worms me, and this is the situation on different devices. I draw them with canvas.drawbitmap (bitmap, srcRect, destect, paint). Okay, I suppose the code code says more than thousand words. // convert pixels to dps xCoord = convertToPixels (100); Int yCoord = ConvertTipics (150); // Definition Destination Rectangle; Sprite is a bitmap object rect destRect = new Rect (xCoord, yCoord, xCoord + sprite.getWidth (), yCoord + sprite.getHeight ()); // Drawing canvas.drawBitmap (phantom, empty, corrupted, zero);

convertToPixels (Boat DP) only formula math.gol (dip * density).

I believe that if I specify the DPS, the aspect that gives a number of pixels with the aspect should be the same on all the devices, eg if I put something on the 10% of the screen size of a device So, those 10% should be kept on a small / large / less dense / more dense screen. But I think my argument is faulty because it does not work. It pulls sprites on different devices at different places.

To summarize:. With a x and y coords, a bitmap object drawing with destRect should be maintained on all devices in relation to 100 DPS canvas size or I should feel like this

Please help me with this matter to me , Because I'm lost in the present, and more literally, in the form of And please do not give me a link to the "multiple screen support" topic on the developer site or similar sites, because I have read them several times and still feel like I did not understand them. Thanks!

Are you sure the fall in PX calculation is correct? I have written the following code to do this:

  public class ViewHelper {public static int getPxFromDip (integer dip) {return (int) TypedValue.applyDimension (TypedValue.COMPLEX_UNIT_DIP, DIP, Application.getContext (.) .getResources () getDisplayMetrics ()); }}   

While application.getContext () applications have extensive references, or provide local activity references.

Comments