I am developing an android application for resolution 320x240.
i want to use this same application for higher resolution is it possible
or i have to design UI for every resolution
Scale your application to be supported in different screen resolutions by following the guidelines at this link.
http://developer.android.com/guide/practices/screens_support.html#screen-independence
Mainly you have to use density index pixels(dp) as the unit to define size wherever you need rather than hardcoding with px
Android was designed to fit different resolution automatically. I would advice to read article from google about it.
You need not to use different layout for different resolution. What you need is just use three different resolution images of same name for all images and keep them in separate drawable folders(named drawable-hdpi,drawable-mdpi,drawable-ldpi) and also use screen width according to screen resolution whenever needed.For example :
int width=getWindowManager().getDefaultDisplay().getWidth() ;
gives you complete screen width.
For more details see Supporting Multiple Screens
Hope this will help you.
Make your design 'fluid' by avoiding e.g. AbsoluteLayout (see the documentation for details). Graphics should be provided for each resolution in the drawable-Xdpi folders.
Related
I'm having problems with images on android, I need to create one image that have the same size in different devices but I don't know how I calculate this using DisplayMetrics.
How can I set the same size in different width and DPI devices?
Short answer: use an amount of dp (density independent pixels) as width and it should look the same on different devices.
To get a better understanding of screen sizes I would recommend reading this article from Google Developers https://developer.android.com/guide/practices/screens_support.html
I think you mean using "in" (inch) instead of dp/dip and worth to know those differences between measurements in android from this question
If you want to display the image in same size in different devices, perhaps you should use Imageview for that, it will show you the image exactly in same size and position in every device.
I want to show some images on the background that is also image. Say my background image contains an empty squares, and I want to show an apple image that must appear exactly in one of that squares.
I have a problems with the apple sizes, as the background scales and fits the screen, but apple image stays the same for the different resolution and the same density devices.
Say I have two ldpi devices with 240x320 and 480x800 resolutions. When I keep my drawable aple file in the drawable-ldpi folder, and use wrap_content for height and width (or fixed dp values) those 2 devices draw the apple with the same size, like it is described in the documentation.
The LinearLayout works slow when I stack them.
Using RelaytiveLayout I must programmatically resize the images which is also "not so good" solution I guess.
I've found a solution here https://github.com/intuit/sdp that maps the dp-s.
They set dimen-s for values-sw300dp to be
<dimen name="_10sdp">10.00dp</dimen>
and for values-sw480dp to be
<dimen name="_10sdp">16.00dp</dimen>
and so on for the different cases ...
So when I set the with of the apple to be _10sdp it means different dp-s for my 2 devices with the same density and solves my problem. Is it a good solution as it seems to be for me?
Is there any other easy ways?
This is indeed the recommended solution as you could see in the iosched github repository which is a generally good source of knowing whether something is a desired common practice at least according to Google since i know they spend a lot of time to create this code to reflect the best practices and obtain the new APIs
Your solution seems good, just as common solution, would be good to use folders described in documentation.
For your case, as easier solution I would suggest to not use an apple image separately and place it in background's square. You can have an image: apple in square, and place it on background wherever you want. An apple will always be in a square and you can avoid tiresome process of creating dimens for each configuration.
I'm developing for android wear, and instead of using 2 different layouts (one for rect, and one for round), can I just use resource qualifiers instead?
For example, I have a layout file: activity_main.xml. It references pizza.png. can I make it so that the round watch (320x320) pulls the image from drawable-w320dp while the rectangle watch (280x280) pulls the image from drawable-w280dp?
Thanks
Update:
There are specific qualifiers as of API 23 (-round and -notround). Check out the official blogpost.
Original Answer:
No, I don't think so. There are no specific qualifiers for form factor (such as -round or -square) and the screen size in pixels is not the same across all square devices. For example, the Samsung Gear Live is 320x320 too.
Moreover, these values are in pixels, not dp as in your example, but this is a minor point.
You should use -nodpi for backgrounds, and -hdpi for rest of graphic files (for now, it might change in the future). There are no shape specific folders as that should be handled in StubView or by fitting content in by using for example BoxInsetLayout.
i want a default pixel size of image in this size should be adaptable for all type of screen size.Anyone can help me please, How to fix image in all type of mobile screen. it cant be stretched out.
thanks in advance.
There is no default pixel size.
You will either have to design images for each bucket you wish to support, or try and create a 9-patch for your images.
The Supporting Multiple Screens document has everything you need to having your UI scale nicely across devices.
Sorry, You cannot have a Default size...
If you are developing a Mobile app, then you should detect the User's screen size and use an appropriate dimension of the picture there....
Have at least three different variations of the same picture for different screen sizes..
Android Has an inbuilt way of doing this Have a look at this : Supporting Different Screen Sizes
I am currently developing an Android Application for a company who are set on having this type of design and targeting Hires devices however I have found that this is very difficult to do and on some hires devices buttons start to stretch.
Screen design here: https://skitch.com/aaronwardle/r7kwa/screen
A few people have recommended making the buttons into Nine Patch PNG files which help with the various screen layouts.
Should I try and get a new app design for this project, which fits all screens using standard controls, or do you think this is achievable?
Looking at stats the most common devices are small screen ones, so creating this application may have a limited audience.
If any one has any pointers on what I could do, i.e. could I make this for hi res screens and within the application have a different layout for smaller screens?
Thanks Aaron!
Your question is too generic to give a simple and quick answer. Furthermore, the layout you want to make is complex and very non-native-looking which complicates matters. Please make sure you read and understand the official docs on the subject from HERE. There is no replacement for that...
The main points that come to mind from that document are:
the <supports-screens> manifest item
Resource directory qualifiers for screen size and density. Appending stuff such as -small or -portrait allows you to create resources that are loaded only on a particular screen aspect, size or DPI. For example, you can create bigger images for bigger screens, or change the layout XMLs for portrait or landscape
Use 9-patch images to scale up rectangles (buttons).
Best practices (as recommended by Google):
Use wrap_content, fill_parent, or the dp unit, instead of absolute pixels
Avoid AbsoluteLayout
Do not use hard-coded pixel values in your code
Use density and/or size-specific resources
I know my answer is a bit generic, but then again, so is your question...
You have to use 9 patch png and also will have to make some changes in the manifest file, to make it screen resolution free. These are very less changes in the manifest file so would not be a trouble.
You can use 9 patch images as well as to design application for different resolutions, you can create different layouts for landscape and portrait.