In my XML Graphical Layout I set the screen to 3.2in HVGA slider (ADP1) 320x480 mdpi.
But it still uses my hdpi-drawable resource. I checked my mdpi folder and my scaled image is there 70x70. But it uses my 105x105 image in the hdpi folder. Oddly, when I use the xhdpi and hdpi screens it works fine, they use their own drawables.
And another questions why does 10.1in WXGA (Tablet) 1280x800 mdpi use mdpi resources considering it is a tablet and has high resolution?
Sorry for my english, any help will be appreciated.
Related
In my application i'm using a background image with some text in it, it's size is 800x1280 (portrait mode)
When running the app on mobile devices , the background image looks great.
When running the app on tablet .. let's say Galaxy tab 10.1 you can see that the text in the background image is a little blurred and little pixeled..
it seems like if the image was smaller than the device resolution and got stretched.. only that image is already in the device resolution
What am i missing ?
Thanks
Your drawable folder contains folders ldpi, mdpi, hdpi, xhdpi - it's for different density per inch.
I suppose your mobile device uses mdpi or hdpi, while tablet uses xhdpi.
To get the best perfomance I recommend you to put 4 different sizes of your image to these folders. The sizes should be 0.75 x ORIGINAL_SIZE for ldpi, ORIGINAL_SIZE for mdpi, 1.5 x ORIGINAL_SIZE for hdpi, 2 x ORIGINAL_SIZE for xhdpi
update: tablets are hdpi, not xhdpi
Your device may be scaling the image somehow. Do you have your image in res/drawable? Try putting it in drawable-hdpi, drawable-mdpi and drawable-xhdpi also. This way it should pick the image fitting your resolution and refrain from scaling anything.
Note that you may want it to be scaled on other resolutions, so putting up different resolutions for different dpis is probably wise. But this is a good way to see if this is indeed the problem.
First of all, did you put your background image to specified drawable folders? :) Your image can be scaled.
If You're using linearlayout, you can check another solution, put imageview and layout into framelayout :)
Here you got examples:
android-scale-a-drawable-or-background-image
scale-background-image-in-linearlayout
:)
I'm developing an app in Android that has a plenty of views(pages). I have to support all phone different screen sizes and density. So i've created different folder for layout : layout-small, layout-large and layout.
Actually I'm not sure about layout-large and layout-xlarge. But it's not the case.
Then I've created different folder for images: ldpi, mdpi, hdpi and xhdpi. In all drawable folders the images are with different size.
I've checked my app with 480x800 160dpi, 480x800 240dpi and 480x800 120dpi it's all OK.
But at 320x480 160dpi app doesn't fit the screen hight. And though I've put a ScrollView still it's not the right way to scroll each new view.
I'm making this app for Android 2.0 and above, so can't use layout-w320dp(like for Android 3).
I need to fit my app at 320x480 160dpi! But how?
Have you looked into using relative screen size, then android will adjust that for you
How do you make layouts for several Android screen sizes?
I created some backgrounds for my application. These PNG pictures are 480x800 format and testing it on my phone (with hdpi res) or on the emulator in hdpi it looks very good. But if I test it in mdpi or ldpi, the backround distorts. Since 480x800 equals to 1:1.666, mdpi format is 320x480 with 1:1.5 and ldpi is 240x320 with 1:1.333, it is natural that the background will not fit all the size perfectly. I can change the backgrounds with sharedPreferences so I cannot use the layouts for this. I do not want to put more images into the app because it's already 3 megabytes (2 megabytes for the backgrounds). How should I solve this? Should I put all the beackgrounds into to app with smaller resolutions (120x200 for hdpi, 100x150 for mdpi...) and the screen will stretch it by itself? I am afraid it would be blurred.
Thanks in advance!
Maybe you could try to use a 9-patch image instead. If that is possible for your background image of course.
http://developer.android.com/guide/developing/tools/draw9patch.html
I use .png as a background for a custom button that I declare in XML like this
android:background="#drawable/samplepng"
But I can't get the resolution right for tablet screens :
For example, my ressource is a 200x200 pixels .png (initially designed for iOS and retina)
I place a 100x100 px version in the drawable-mdpi folder and a 200x200 px version in the drawable-xhdpi folder.
I also need to have a layout for a typical 320x480 screen in the layout folder and another layout for 10" tablets in the layout-xlarge folder.
The size of the button is 100x100 dp in the normal layout and 200x200 dp for xlarge layout, so that it looks right.
With the Android emulator, a 10" tablet uses mdpi ressources and xlarge layout.
As a result, the button background is drawn with a scaled version of the 100x100 image which looks very blurry, as opposed to the crisp 200x200 original image.
If I don't use a mdpi ressource, it looks blurry just as well.
Am I doing something wrong ? is it only an emulator problem and it looks nice on a real device ?
Please help, I read 10 times google's doc but can't find an answer.
If you don't launch the emulator with 'Scale display to real size' checked, then it will always use mdpi drawables.
See here for more.
Your issue might be in the android version your targeting. Try switching the emulator to android 3.0 and 3.1.
Which layout should I use for HVGA screen? For a small screen, I put all my XML files in layout-small directory. Similarly for devices like Nexus S and Samsung Galaxy S which have a resolution of 480 x 800. I put all my XML files in the layout directory.
But for HVGA I didn't find any solution. Where to put the XML file for the HVGA device?
Is there any option like layout-small that I can do for HVGA devices? When I run the for HGVA device it takes the layout from the layout directory but as the resolution for HVGA devices is smaller than Nexus S devices, the layout does not properly appear. So I want to know.
To target HVGA 320*480 use:
layout-normal-mdpi
At the same time to support WVGA screens and i.e. Galaxy Tab you need:
layout-normal-hdpi
folders.
According to this
Normal: Screens that are of similar size to a medium-density HVGA
screen. The minimum layout size for a normal screen is approximately
320x470 dp units. Examples of such screens a WQVGA low density, HVGA
medium density, WVGA high density.
MDPI: Medium-density (on traditional HVGA) screens; approximately
160dpi.
You should try: drawable-normal-mdpi
you can use the layout of layout-large
you can refer following link ....
http://developer.android.com/guide/practices/screens_support.html