I am currently putting together an application for my HTC Evo 3D phone which has a screen resolution of 960x540. I have set up a custom layout configuration for designing the interface at this resolution. When in this configuration the widgets (texts views, seek bars etc.) appear small and compact, sparse on the screen. Whereas when I launch the application on my phone the buttons are considerably larger and fill the screen more. Is there some setting in Eclipse that will allow me to view the layout in the editor exactly as it would appear on my phone, allowing for easier design of the interface.
Many thanks, Mat.
with relevant code would be easer to help, however, if you are using dp unit measure, sizes will change according to resolution:screensize, not just resolution. I think also a "wrap_content" given to a textview/button etc. would change in size, because font size would be in sp. So, look if there is any emulator configuration that fits real device resolution AND screen size.
Take a look here for more info about measure units.
EDIT
so are you seeing it in eclipse in the graphical layout of yourlayout.xml? on the top bar of that window there's a dropmenu for display configurations, change it to see the layout in different screens (I don't see any 960x540 btw). however, if you really want to develop for one single device is a matter, but if you're going to release the app for different devices, you need some strategy to make flexible layouts. this is very useful.
Related
I have a question about checking layouts on Android. I know all basics about screen sizes (size vs density), I usually make layouts with listview or scrollview, so no matter height of device it'll just show more or less content. Problem is I often have a particular layout to make (from iPhone "render" usually). Let's take an example:
I had to made 3 buttons in one row, so I've made LinearLayout with 3 buttons inside, which has layout_width 0dp and layout_weight 1. That did the work. Or it seemed to. I use Android Studio (latest version) to build my layouts, so I can see a preview on different screen sizes and densities. I used "Preview all screen sizes" as well I've looked into "Generic phones and tablets". All were good. However I've sent my apk to a friend, which send me a screenshot that showed one letter from buttons went down to a second line. I was using;
android:textAppearance="#android:style/TextAppearance.DeviceDefault.Medium"
His phone is LG L65. I had to make font size smaller, because it appeared really big and didn't fit. How can this be even smallest densities were all good and on this phone wasn't? How can I be sure any layout will fit? Isn't using built-in font sizes a good idea? So I have to own a lot of devices and make different font sizes, margins etc for all combinations of screen sizes and densities?
You have to take in account that the font size can be bigger than expected by a system settings. If you want your button to be single lined, you can use android:singleLine="true" on your button. This might ellipsized the text if needed.
If you want single lined button without ellipsized, you have to build a custom view that down scale the text when needed ...
I am developing an Android Application that supports all kind of Android devices like mobiles and tablets. But it's time consuming to create multiple folders (small, normal, large and xlarge android xml layouts) to support all the Android devices. Is there any way to build an android app that runs on all android devices without creating these folders:small, normal, large, xlarge etc?
You only need to create unique layouts (ie. *layout_mdpi* ) if you want something unique for that particular screen size.
If you want to use the same layout on all different screen sizes, you will only need to create a single layout (in the layout folder).
Only if you want to customize a particular layout would you need a new FOLDER in layouts (named: layout_mdpi) in that folder you would have multiple copies of customized layout with same name (ex. my_layout.xml)
To clearly answer your question - you will only need the layout folder and no other ones in your casel
Ex.
res\layout\my_layout.xml // this folder is all you need if this layout will work on all screen sizes
res\layout_mdpi\my_layout.xml // you ONLY need this if you are presenting something unique on this screen size.
In Android we need to maintain different folders for the layouts with different resolution reason behind it is the use or the resolution of the Android Device on which the application gonna execute.
small Resources for small size screens.
normal Resources for normal size screens. (This is the baseline size.)
large Resources for large size screens.
xlarge Resources for extra large size screens.
Android OS select the specific layout it self by checking the compatible device and its resolution.
So, better to create folders to support in multiple screens
For More Info refer this
Is there any way to build an android app that runs on all android devices without creating these folders:small, normal, large, xlarge etc
Consider this, you have a button (with match_parent) that stretches full width of a screen in portrait mode of a 4 inch phone, that's fine it looks alright, but then that same layout on a 10 inch tablet in portrait is now 3-4inch wide, that's not great looking.
"So what" you say, make it wrap content, okay then so the button now only fills up part of the width on phone, still looks okay but then on a tablet you have huge amount of space now either side of the button, maybe that's looks okay, maybe not.
Maybe same button on a smaller screen takes up too much space?
Now apply the above to every single layout element in your app.
Do you think it'll look good, using the same layout, do you think your users will be okay with an app that was so little care to its UI and UX?
SO, in conclusion, yeah it's possible to only use one eg normal, for all devices but it'll probably look terrible on most of them.
I created a simple Android app. It only has one activity and one view.
The app was designed for phones. I used the "device independent pixel" unit (dp) for all of my UI element measurements, and RelativeLayout for most of my layouts. The app looks good on a small screen.
On a large screen (such as a tablet), all the elements are tiny, spread apart, and there is a large empty space at the bottom. It's true that the physical size of the UI elements is roughly the same between the tablet and the phone, which is what the dp unit promises, but it's not really what I want for this app. I'd like the whole interface to just get bigger and fill the screen as much as possible, like when you run an iPhone app on an iPad and push the "2x" button.
What's the best way to do this? Do I have to write separate views for each screen size? Should I use pixels (px) instead of dp?
Thanks.
Using px as a measurement would actually be worse - as new tablets have high DPI screens, meaning 100px is going to be visually smaller on a tablet than it would on a mid spec phone.
Your best option is to use layout overrides (layout-sw600dp, layout-sw700dp). Although simply enlarging a phone layout is strictly discouraged.. if you want to take the shortcut all you have to do is copy your phone layout into the sw* folders and tweak all the dp measurements.
You will also need to force the tablet into portrait mode using:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
I realise this topic has been covered to death, and I have read the official and unofficial developer guides on it so know the theory. But I'm still unsure which path to take to ensure my app looks good on multiple screen sizes. My app is a simple navigation style app which is designed to be portrait only. At this stage I'm not interested in making different designs for landscape or multi-pane screens for tablets etc. I just want each screen to be scaled up/down so it looks in proportion with the screen size it is being displayed on - i.e. text and images are sized up/down as appropriate. I designed the app for a classic 480x800 hdpi device which it looks great on, I just want to make it look in proportion for the Galaxy S3/Nexus 7 etc. I'm already following these guidelines :
Using RelativeLayouts
Using DP units for padding/margins
Using SP units for fonts
Using 9-patch images for buttons
However I'm finding it still looks small and a bit lost in the middle of the screen on the larger devices. In particular, my main menu screen is a grid of 6 image buttons which I can't get to scale well. I don't want to have multiple copies to maintain of the same screen (normal/large/xlarge), just want one layout. I was considering the following :
Using value-normal/value-large etc. folders to store XML files with DP/SP values for sizes of images/text
Changing RelativeLayouts to LinearLayouts with weights (although I initially struggled with LinearLayouts and changed to RelativeLayouts
Are either of these valid approaches, or is there a better approach?
Personally, I would go with the first option. While this will work well for phones, it will make the layout seem somewhat bloated on tablets. Hence, another approach would be to create separate layouts for tablets and place them in the layout-large and layout-xlarge folders for 7" and 10" tablets respectively.
I have almost finished my app for android, the problem is when i test it on multiple screen sizes the layout of items such as padding etc, seems to be incorrect. I don't understand how I am supposed to support all screen sizes, because I have used all 'dp' values for the text and sizes for padding etc. I am using the 'background' as an image which fills the screen, and the background includes the layout of buttons and boxes that will have textviews overlaying them. I have been testing on my HTC desire and I have just noticed this issue. I assumed that it would all be okay seeing as I have been using dp for all measurments etc. Any tips to fix my layouts would be appreciated as my app is pretty much good to go apart from this :(
Read the following links very carefully you will get the best way to do:
Supporting Multiple Screens
Support for Multiple Screen Resolutions
Support for additional screen resolutions and densities in Android
compatible-screens
MultiResolution - Multiple Resolutions