I've got a Pixel XL and I like to keep the screen size set to small. However, the default size for the Pixel is defined by Google as xxxhdpi, so my increasing the dpi isn't "detected" so no scaling is triggered.
When making an app, I can't seem to create a folder called xxxxhdpi or xxlarge, so I'm kind of at a loss as to how to define the layout for the higher DPI.
I found a resource suggesting to simply define the dpi, i.e. calling the folder 720dpi, but Android Studio throws a compile error if I do that.
Does anyone have any idea how I can make the app show up correctly on my phone?
Can you make minmap-xlarge resource folder? but not sure whether Pixel xl device will read from it. Here is the screenshot.
Related
I have been struggling with this problem about a week and can not figure out how to make it work. I have some views on a screen. And one values\dimens.xml(sw320dp-xxhdpi) resource file. Also I have nexus 5.2 1080*1920 420dpi and nexus 5.0 1080*1920 xxhdpi. The layout appears differently on both screens. How to make it display the same on each device?
What resource file should I add (if it is any)?
How to add for example values\dimens.xml(1080*1920 420dpi)?
I think your layout is simply built as poorly scaling. Unless you have some very specific use case, you need to make sure your layout fills the area it is provided with regardless.
As for the resource folder, if you want to make sure the same layout file is used on large screens, it is enough to put it in the folder layout-sw360dp. If you have xxhdpi devices with the resolution 1080x1920, Android will select the same file for both since the smallest side will be exactly 1080 / 3 = 360 density-independent pixels.
How to make it display the same on each device?
In general it's impossible for all Android devices. I think best solution - using VectorDrawable or SVG format and scale vectors for each device.
I thought I had this device density/size thing down, but apparently that is not the case. I have created a new hardware definition within Android Studio using the following dimensions and size.
9.7"
768 x 1024
This results in an ldpi device, which is what I am after. This was mirrored off of the HP Touchpad device.
I am using several dimens files within my application which are contained within their associated values folder with 2 resource qualifiers each. A typical values folder in my app looks like this.
values-sw320dp-xhdpi
Using the information above, I believe this should result in the system looking for the dimens file in my values folder shown below.
values-sw480dp-ldpi
I arrived at this conclusion by taking the pixel dimensions of 768 x 1024 and multiplying them by .75 which would result in a with and height in dp of 576 x 768. Since the smallest width is 576, this should use the values folder referenced above of values-sw480dp-ldpi.
I know that it is not using the values specified in this dimens file because the value shown in the layout is from one of my other values folder/dimens files. Additionally, it is not actually using the values from the file that the layout is referencing either, as changes to that dimens file have no impact on the layout. It simply is stopping on the first one seen (or something) but not actually using the value. I have encountered this situation many times and the issue is always fixed by getting the "correct" values folder defined with the appropriate resource qualifiers. The issue here is that I don't know what the system is actually trying to use and it clearly is not coming up with the same calculations I am.
Here is a screen shot of the device I have build in Android Studio.
Android supports combination of qualifiers in defined order of priority. Here in Table 2. you can see this list.
And here you have fine description of how Android finds the best-matching resources.
Also, I wonder what is the reason you create values folders with Screen pixel density (dpi) qualifiers. I could be wrong, but I think that density matters only with drawables/mipmaps etc.
I am developing app.I have only layout folder with xml files,it is showing properly in more pixel screen ,but when i see my app in less pixel screen the text is big not same as more pixel screen As per android developer site, I came across layout-sw320dp ,layout-sw480dp. So I have added the xml files into layout-sw320dp,layout-480dp and made changes like text size and margin,then when i run them with sw-320dp in less pixel screen i can see text size same as more pixel screen,but when i run with sw-320dp the same in more pixel screen, the text is small ,it is taking layout from only sw320 actually it should take from layout folder.I d'not know where I am wrong can any one tell me.
screens with only layout folder
[![screen in less pixel density[![screen with more pixel][1]][1]][2]
screens with layout-sw320sp
[![screen in less pixel [![screen with more pixel density][3]][3]density][4]][4]
[1]: http://i.stack.imgur.com/6rTNw.png
[2]: http://i.stack.imgur.com/uHRkx.png
[3]: http://i.stack.imgur.com/qhcmk.png
[4]: http://i.stack.imgur.com/Z5PE0.png
You are not supposed to pick what resource size is shown, android does that depending on the device used at runtime. Your job is to set the resource in the correct folder for example res/layout/mylayout.xml and res/layout-sw480dp/mylayout.xml res/layout-sw320dp/mylayout.xml sw is smallest width of screen, 320 is a number, dp can be thought of as pixels. This concept of putting resources in folders with special names and allowing android to pick the most sutable special name/folder for the job works for any resource. Strings/languages, images/for device screen size,night/day,orientation-|.
Something is really wrong with Android.
I have one Device with a "Normal screen and MDPI" (LG Optimus 2X P990)
I have one Device with a "Normal scren and XHDPI" (Samsung Galaxy S3)
I try to have all layouts in one single folder, for all views. If I change the color/text/whatever on one view, it goes globally. To have that value such as a "Color" to be located in all different layout means I have to change all the files when changing something so rudimentary as a color, or textsize.
Then in each "values-normal, values-xhdpi, values-large" I have set all settings unique to that device.
Example "values-normal"
<dimen name="text_small">10sp</dimen>
Example "values-xhdpi":
<dimen name="text_small">4sp</dimen>
Example "values":
<dimen name="view_textview_title">#dimen/text_small</dimen>
Currently, the MDPI device doesn't load the values from the "Values" folder, only when added to "values-normal" and the XHDPI device doesn't load the "values-xhdpi" if there is a Normal folder.
Well, to say the least I can't optimize the App for two different devices. That's what wrong.
Cause, I read that the "Normal" folder overrides the "XHDPI" folder for a Normal screen device with XHDPI Density. But to be able to see the Title text I have to set the text on the XHDPI text size to something like "4sp" while on the Normal with MDPI it's about "10sp".
A higher density will multiply the value more, a lower - less. Am I right? Then this way there is no possible way to optimize an App for two different devices with just a Density change. Each screen size with it's density size needs it's text size.
So, my question is the following...
Can I combine "values-xhdpi-normal" "values-mdpi-normal", "values-hdpi-normal" and such?
Otherwise, I have to make the App ugly for some devices and look good on some. I like probably more like me, don't use "TextSize = 10" on the whole page. A title is a title, larger, a menu is a menu, smaller text, descriptions on a menu even smaller. There you go.
Reason I'm asking is because I don't wanna reset the current layout without it being possible, too much work for nothing otherwise and Eclipse is buggy enough with it's productive approach of having to add a single line just to force a reinstall when a library has changed or restart the whole environment for it to understand that something's changed - especially with Values!
I always used the standard emulator when testing and thought it was about time to see what it looked like in a higher res/density setting. I ran my application using WVGA854 which has a density of 240 (rather than the 160 I usually used). The result is my application sitting as its old size in the center of the screen. I don't specifically hardcode the application size anywhere that would produce this (except for background images, but there are other things like x,y positions that are still limited by the old size). What gives? I move over the high res images into the correct folders but it still appears to be forcing my app to a smaller size? The background below is set to 854 width in the HDPI (and MDPI folder) but it is still cutting it off? Using a surfaceView to draw the bitmaps.
Add the <supports-screens> element to your manifest, saying that you support large screens.