I saw one android app my galaxy tab(1024*600), it has fixed resolution 800*480.
How to fix my app's resolution like 800*480?
my client wants to fix app resolution..
You can explicitly define your layout width and height in layout xmls to be 800*480 for all the un-supported resolutions like 1024x600.
A list of sample layout folders:
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
In case of 3.2 or later, you can define layout files for tablets as well:
res/layout/main_activity.xml # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)
I don't recommend fix your width and height to a specific value but since it's client request, I guess you have to take it.
Or you could set target sdk version to 1.5 or 1.6. I haven't really tried it yet, but I read somewhere that doing so limits the application to be displayed in a lower resolution.
Related
When I create small,normal,large,xlarge layouts:How Android Detects Screen Size phone for use this layouts?base on dp or dpi or px?
Is the result always right?Because some devices are smaller in physical size but the density is higher so if based on density this detect is not always correct.
Am I right?
Android uses dp, but there are a lot of variants you can create in your resources for example
res/layout/main_activity.xml # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
You can cover more resolutions using different configs, but I think is hard work to cover everything, because how I said we have different resolutions, screen sizes and now we have notch.
res/layout-560dpi/
res/layout-ldpi/ ...
Bellow, I copy a link about this
https://developer.android.com/training/multiscreen/screensizes
Which are the value folder names and layout folder names that I can used to support multiple screen sizes and dpi values. Looking for the complete list of devices with 4.1+
Thank you
-For layouts you can specify
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
-- If you want to specify the screen basing on the dp you can spicify the name as
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
-- If you want to specify basing on the smallest width you can specify as
res/layout/main_activity.xml # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)
[for more detail click here][2]
Under your project, you will find a folder called "res". You need to supply different images to different screen sizes inside the drawable folders.
For example, inside the folder drawable-hdpi you will add your hdpi images, inside the folder drawable-mdpi you will add your mdpi images and so on...
Also, if you have a missing folder, for example for the xxhdpi dpi, you can just create the folder under the res folder (drawable-xxhdpi) and add your xxhdpi images.
Now I'm supporting multiple resolution with multiple layout folders.
I'm using android development studio and I made 3 different folders.
layout
layout-large-port-1280x720
layout-normal-port-800x480
and I tested on 800x480 and 1280x720. 480x800 worked well, but 1280x720 follow 800x480 folder's dp and UI.
I don't know why this thing happens to me and I don't know how to solve the problem.
Why it doesn't work and what should I have to do?
For Different screen size, The following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for small, medium, high, and extra high density screens.
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
Thats code in the Manifest supports all dpis.
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
make sure you have given the corresponding drawables in drawable-xhdpi
I don't know on what basis you're creating the App. But it's better to avoid creating layout for specific screen sizes.. Instead you would give the following:
layout-small-port for devices like samsung galaxy y
layout-normal-port for devices like galaxy s2
layout-large-port for devices like nexus 7 which is 7 inch
layout-xlarge-port for devices having more than 7 inch size
If you specify the screen size, you can't support more number of devices
U should use:
res/layout/main_activity.xml # For handsets (smaller than 480dp available width)
res/layout-sw480dp/main_activity.xml # For phones (480dp wide and bigger)
res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)
res/drawable – The default image folder
res/drawable-sw200dp
res/drawable-sw600dp
res/drawable-sw800dp
This is how my layout looks on the phone (landscape):
button wrapper (marginTop 10dp, margin left 5dp and 3 dp between buttons)
The problem is when I run the same layout on the tablet:
As you can see there is an extra space below the button wrapper.
Am I need to create different layout for each device display?
Yes you should create another layout for tablets. if the layout for the phone comes in tabs obviosly it will get smaller..youcan go through this oink about creating different layouts for different displays..Mainly for layouts will be provided for an app
layout-small ,
layout ,
layout-large ,
layout-xlarge,
Link
Iam not getting what your actual point is..but yes for tablets you need to make different xml layout files which are put under layout-large and layout-xlarge(depending upon your requirement) folders. And if you'r not doing so then your tablet will render the layout from your default layout folder.
Is this what you were asking ?
You can do with help of this
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscapeorientation
for drawable
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
I think you need this
res/layout/main_activity.xml # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)
http://developer.android.com/guide/practices/screens_support.html
i am working on 2.2 version of android and xml is designed according to this version
Specification of emulator : version 2.2, Built-in : HVGA , Memory : 1024
and now i need this application to be transformed into 4.0 version of Samsung galaxy s3 but the screen are very streched and does not look good
thanks in advance if any help.
You have to create multiple resources for your app. Android has 4 resolutions (ldpi,mdpi,hdpi and xhdpi) and 4 generalized screen sizes (small, medium, large and extra large). So you have to make 4 layouts (or 3 if you don't plan on supporting tablets, since tablets come under the extra large category) to support the screen sizes.
Here's a general guide:
put layouts for small, medium, large and extra large in your res/ folder as follows:
res/layout/sample_layout.xml // default layout
res/layout-small/sample_layout.xml // layout for small screen size
res/layout-large/sample_layout.xml // layout for large screen size
res/layout-xlarge/sample_layout.xml // layout for extra large screen size
you can also use
res/layout-land/sample_layout.xml for landscape orientation for all screen sizes or you can target landscape layouts for specific screen sizes as res/layout-medium-land/sample_layout.xml
note that all the layouts have the same name.
once you have your layouts ready, you need to take care of image resolutions also
once again in your res/ folder add images like this:
res/drawable-ldpi/sample_image.png // low density
res/drawable-mdpi/sample_image.png // medium density
res/drawable-hdpi/sample_image.png // high density
res/drawable-xhdpi/sample_image.png // extra high density
once again, all the images have the same name.
general guidelines for designing images are:
ldpi is 0.75x dimensions of mdpi
hdpi is 1.5x dimensions of mdpi
xhdpi is 2x dimensinons of mdpi
generally, I design mdpi images for a 320x480 screen and then multiply the dimensions as per the above rules to get images for other resolutions.
Android will automatically select the best combination of layout and image depending on the device. For example, for a high resolution medium size device, layout-medium and high density image will be displayed to the user.
Make sure you create emulators for all these combinations and test your app thoroughly. here's the official docs for more info:
https://developer.android.com/guide/practices/screens_support.html
You have to maintain your xml files in
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
Check this Supporting Multiple Screens for how to design your layout for supporting multiple screens
and also for images use
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density