When calling texSubImage2D, I seem to be getting the bitmap I pass in positioned by its center on a Samsung Galaxy S3 / Galaxy Note 2, and by its top-left on a Samsung Galaxy S2.
It's making my textures totally wonky on the S3 / Galaxy Note 2.
Can someone confirm that there is indeed this difference in how this method offsets the bitmap, between these devices?
How do I ensure consistent behavior for texSubImage2D across all devices?
texSubImage2D behaves consistently, I'm guessing that you are loading textures from resources and they are upscaled on note 2 / S3 (both are xhdpi devices) when compared to S2 (hdpi), and you probably use fixed size texture hence a difference.
Related
The Android SDK recommends the use of
ViewConfiguration.getScaledTouchSlop()
for detecting if the finger on the touch screen has been moved. According to Android, the ScaledTouchSlop depends on the device, and with that upon resolution and screen sensitivity.
I have written a view where the user can use Canvas for painting on the screen, and I have realized that painting works differently well on different devices. Further investigation showed that ScaledTouchSlop seems to be defined by the device manufacturer and varies a lot between manufacturers. For example
The ASUS Memo Pad 7 has a ScaledTouchSlop of 11 pixels on a 7 inch screen with approx. 1280x720.
The Samsung Galaxy Note 2 has a ScaledTouchSlop of 32 on a 5.5 inch screen with approx. 1280x720.
Both screens have about the same resolution, so when looking at the ASUS device, I would have expected ScaledTouchSlop to be around 14 on the Samsung device (11 pixels * 7 inch / 5.5 inch), but it is 32. This results in not being able to fluently draw on the Samsung, as smaller strokes are often not recognized.
Sure, I can just define my own "slop" for drawing, and if I do drawing works perfectly well, also on the Samsung device. But I guess that would cause trouble on other devices, which are smaller or have a less sensitive screen.
Is there are a way how the touch slop should be calculated for drawing or does anyone have a recipe that works well on all devices?
I'm currently working on my application, which tries to support different screen resolutions but I noticed a major problem with my layouts. I'll explain:
I have two folders in my res folder. They are called "layout" and "layout-sw360dp" which is meant to support big screens like Samsung Galaxy S4, HTC One, etc.
Now, when I try to run my application on my private phone, galaxy S4, the app looks fine and all of the images and the components are perfect.
But when I try to run my app on an HTC One device, suddenly the layout looks small, like very small. It supposes to fit the entire screen, like in my galaxy s4.
It's like HTC One and Galaxy S4 don't use the same layout folder, although their screens sizes are almost the same.
If you guys can clarify this matter for me I would really appreaciate that.
Edit: I have tried to run my app on an Samsung Galaxy S5 device and it looks find, like the way it should. What is the problem with HTC One?
Physical size is usually measured in inches, it simply tells you the real device's screen size
dpi, is NOT correlated with it. Dpi expresses screen density, how many pixels are shown in a given area (usually a square inch). It could be considered as a measure of screen quality.
Resolution is given by the product of the two; it expresses the total number of physical pixels on a screen.
android:anyDensity="true"
Samsung Galaxy S4, HTC One have different physical size : DIFFERENCE
Refer this for how to choice best resolution : DOC
I'm testing my app on 2 devices - a Samsung Galaxy S3 and a Samsung Galaxy Note 2. Both have the same screen resolution and apparently both use the same xhdpi density even though the Note 2 has a considerably lower physical dpi.
My icons on the action bar look smaller on the S3 than on the Note 2. Why is this so, and how can I fix it so that it looks consistent?
Samsung Galaxy S3
Samsung Galaxy Note 2
It turns out that even though the resolutions I was using for the individual pixel densities were correct, the actual icon area within the image file had an incorrect size. I followed this guide at iconhandbook.co.uk/reference/chart/android/ and now things look consistent.
I have been laying out some Android xml screens on a Galaxy Samsung Tab 7" GT-P3110 which has a screen resolution of 1024 x 600. It is running Android ver 4.0.3
My customer however is running a Galaxy Samsung Tab 7" SPH-P100 with Android 2.2 with the same screen size and resolution.
When the customer is viewing the screens I have created they are being cut-off width ways.
Both devices appear to have the same size and resolution and I'm trying to work out why there are differences in layout ?
Galaxy Samsung Tab GT-P3110
http://www.samsung.com/uk/consumer/mobile-devices/tablets/tablets/GT-P3110TSABTU-spec
Galaxy Samsung Tab SPH-P100
http://www.samsung.com/us/mobile/galaxy-tab/SPH-P100ZKASPR
I've done some digging into this...
Here on SO, there are a few comments like "device manufacturers can select the density of their device to achieve a desired UI -- for example the Samsung Tab uses a density that is a fair amount larger than the actual DPI, resulting in an overall larger UI." from
basics of device-independent-pixels, and this is further reported on other sites...
One user has dug more deeply into this - and discovered that the original Galaxy Tab 7 reported that the Galaxy Tab did not obey the developer documents:
160dp is always one inch regardless of the screen density
but instead reports its display as hdpi instead of mdpi. The explanation on the Google blog for this is:
In this context, the Samsung has another little surprise: If you do the arithmetic, its screen has 170 DPI, which is far from the densest among Android devices. Still, it declares itself as “hdpi” (and as having a “large” screen size). The reason is simple: It looks better that way.
For more info on this, see:
Understanding Samsung Galaxy Tab screen density
and http://realmike.org/blog/2010/12/21/multiple-screen-sizes-with-processing-for-android/
and http://android-developers.blogspot.co.uk/2010/09/screen-geometry-fun.html
With this in mind... the only remaining piece of the puzzle is what's happened in the Galaxy Tab 2... well, my guess is that Samsung have decided in ICS to change the Galaxy Tab 2 back so that it "correctly" reports itself as a medium density rather than high density device...
... and that's why your Galaxy Tab 2 displays content so differently to your customer's Galaxy Tab 1
i recently developed a game, for Android 2.3.3, and strangely im finding few weird behaviour in different phones,
for example
An explosion sprite(256x256 pixels) divided into 4x4=16 images, when displayed is being displayed as a 2x2 image in Samsung Galaxy Ace 2.3.3 and Samsung Galaxy Y, 2.3.5 ,
Also, the accelerometer works in a haphazard form in Sony Xperia 2.3.3 and Samsung Galaxy Ace.. either its too slow(and takes touch gestures after 3-4 second gap) and Android OS throws a Alert box saying, the app is not responding, else its too fast.
Strangely, The game works perfectly on a Samsung S2, just like it plays on the VirtualBox..
please help me, b'cos this is my college project, and I wont even be able to put this up in the market if such a queer problem exists!!
Thanks in Advance!!
I think I have the same experience with the graphics problem:
From your code, I'm guessing you may have pre-computed "width_explosion" and "height_explosion" from the image height/width you have seen in an image editor and using the same values on different devices.
The device you have listed have two different DPI values as Android knows: 240, or MDPI (Galaxy S2) and 120, or LDPI (Galaxy Ace and Galaxy Y). Note that Galaxy S2's DPI is exactly twice as Ace's and Y's.
Android makes it handy for app authors by assisting them in manipulating images. When images are read from resources through getDrawable and are ready for rendering on screen Android resizes the images with respect to 160DPI, so that they will have the same length measured with a ruler on screens with different pixel densities. For example, if an image with 128x128 pixels is 2cm long and 2cm wide on Galaxy S2, it should be 2cm long and 2cm wide on a Galaxy Ace. However, to cover the more pixels on a Galaxy S2, it's resized to 192 x 192 pixels when drawing on a Galaxy S2, because its DPI as the Android system knows it is 240, 1.5 times the DPI of an ADP1 (HTC Dream). Similarly, the image will be resized to 96 x 96 on a Galaxy Ace or Galaxy Y.
The source rectangle in canvas.drawImage, unfortunately, refers to the number of pixels in the resized bitmap. That means the same source rectangle used in your code sample covers 4 times as many pixels on a Galaxy Y as it does on a Galaxy S2. I guess you are describing in the question that "the same sprite file looks like it was divided in 2x2 on a low DPI device but it should be divided by 4x4".
The following example illustrates what happens when I'm trying to replicate your question with devices with different DPIs.
I cannot post images, so I have put the images here (it's my blog):
http://edgeofmap.com/blog/2013/05/android-bitmap-over-devices-of-different-dpis/
Not sure what to do about the graphics issue, but for the accelerometer each device acts differently. Use event.sensor.getMaximumRange() in your onSensorChanged() to get the maximum value and base your actions on that or a percentage of that.