I have to write an app for tablet and for phones too. The two app has the same functionality, but they have absolute different GUI.
For example the phone have 2 button on the main screen, but the tablet going to have 5, because we would like to use the space what we have. I know, I˜m able to define different layouts, depends on dpi, but how should I handle the layout-s in the Activiies? I think, to use if(sdkVersion >=11) bla..bla... is not will works through the hole code and the hole project! Is this the situation where I have to use multiple application support ?
readed articles:
http://developer.android.com/guide/practices/screens_support.html
http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources
http://developer.android.com/guide/market/publishing/multiple-apks.html
I don`t understand how should I handle this problem... please if you able help , thx
Put your tablet layouts in res/layout-large/. Put your phone layouts in res/layout/. Name them the same. Your activities will load the right ones based upon the device they run on. When you call findViewById() to retrieve the extra buttons, and see that you get null back, ignore them.
You may need additional layouts in places like res/layout-large-land/ (landscape for tablets), res/layout-xlarge/ (if you want to handle 10+" tablets differently than stuff in the 5-9" range), res/layout-small/ (if you want to handle <3" screens), etc.
Related
How to make sure that my App's popup or text appears exactly how I intended it to appear in all screen sizes? I want the aspect ratio of the popup to appear same and all the text that appears at the time of designing the popup to be same in all the devices.
Imagine an image who's size and content will be same across devices. But for some reason I can not use image here, the requirement is to use popup with text and butto. I dont want any screen to cut the popup or make the text of the popup disappear or turn to crap.
I can not do testing with one device at a time as I read on a site that there are over 10,000 android devices :|
Is there anyway or any tool part of Android Studio which can like quickly draw outlines of all the phones screen sizes to help me understand what aspect ratio is right for my popup?
Im a noob so my question may not make sense to you so please bear with me.
Unfortunately it's going to be nearly impossible to get things to appear 100% the same across all devices and browsers – Android runs on all sorts of devices and there are probably hundreds or thousands of different possible screen sizes, in addition to browser and operating system quirks. Start with identifying specific devices and screen sizes you wish to support. See Android's screen compatibility overview for some good information on this topic.
If possible look at user analytics to narrow down the most common devices, operating system versions, and browsers, then test against those.
I am working on a widget. On the typical phone, I would prefer it to be 4x2, filling the width of the home screen. However, on some larger phones (i.e. Samsung Galaxy Mega), the launcher has 5 cells' width. I am trying to find the best way to automatically change my widget provider to be a 5x3, based on the launcher cell dimensions.
Currently, we have two providers: a 4x2 and a 5x3. Since we only want to show one (4x2) on normal-size phones (they don't support 5x3), we do a runtime check when the widget is added to check if the device model matches one of the models with a 5-cell wide launcher. We then disable the other widget provider component. However, this isn't ideal, as the 5x3 will show up temporarily in the app drawer and cause the launcher to force close if the user tries to add it.
Any thoughts on how to work around this? I realize I most likely won't be able to read exactly the cell-width size, as there are tons of launchers, and there isn't an API to check. However, I think we would all agree that there must be something better than keeping a static list of devices that have a 5-cell screen (not to mention people with custom launchers can set a range of widths).
I have thought briefly on using the resource folder qualifiers (sw720dp, etc.) ...but that still doesn't solve the issue of determining what the user's launcher's width in cells is.
Thanks for the help,
Drew
P.S. I also realize that a similar question was asked here: Appwidget Maximum Width that fits all screen sizes with no comments or answers. Any input would be much appreciated.
Any thoughts on how to work around this?
Allow your app widget to be resizeable, so users who want it to fill the home screen width can elect to do so.
Preface:
I moved to the S3 from an old flip phone with a small keypad with which I could easily type things like a telephone banking passcode or the like, shielding one hand with the other as I typed.
With the S3 smartphone, the dialpad is huge, making it hard to shield one hand with the other, and the required finger movement is too great and too easily observed.
Question:
Is there any way to either:
(A) Shrink the size of the "in call" dialpad used by the S3, through any means, even a screen scaler or spliiter, or
(B) Achieve a similar end using a custom dialer?
If I rotate the phone to landscape mode, I do get a nice sized, smaller dialer initially, but once I enter the call (say, voicemail), it jumps back to portrait mode and the stock dialer. From the research I've already done on custom dialers, it seems that they don't work once a call starts, so I'm not too hopeful.
Is the only solution to root the phone and hack it very deep? (Obviously, anything can be done with a rooted phone if you know what you're doing.)
Unless the phone provides such a setting, not really. Generally you cannot change/influence apps other than your own, and the only proper way to do this would be to right a custom dialer and replace the system one. A slightly easier way might be to replace the dialer keypad images with custom ones with smaller font, etc. and just repackage the app, but that won't change the overall layout.
Much better: don't use telephone banking, use their website, smartphone app, etc. (if available, if not bug them to create one :)
I'm writing a game for Android and am laying out the playing screen myself, handling both vertical and horizontal orientations, and haven't done anything if the width and height are the same.
Does anybody know of at least one Android device that has a perfectly square screen resolution?
The MotoACTV is 220x176 (not square but close), the WIMM One is 160x160 (square).
The MotoACTV has been rooted, but the default device runs a customized Android. It's a pretty cool device, though. The WIMM is slick and runs a more-standard Android.
None the I'm aware of. Every device I'm familiar with has a distinctive "portrait" vs "landscape" mode.
It would probably be wise to make sure your code can always gracefully handle portrait vs landscape - even if you ever happen to run across a square device.
Conversely, if you want a square - just "crop" the image appropriately. The cropping, of course, will become "zero" if you ever encounter this hypothetical "square screen". :)
This is a rather late answer to this question, but things have changed somewhat since then, and although there are still no mainstream Android devices with square screens, there are 3 square BlackBerry devices (Q10, Q5, and Passport) that can run Android apps, and so would fall under that criteria. Interestingly, when an app is run on a square BlackBerry Passport, and the device is rotated to its side, the app also rotates, however none of the onPause(), onStop(), or onDestroy() events are called, and so the activity is not destroyed and re-created, but the current activity layout is re-used. So, in that respect, nothing happens, and you don't have to worry about saving/loading resources and such.
This behaviour is actually built-in in Android -- it will only destroy and re-create an activity, if the screen dimensions change. The API docs don't talk about this edge case, as there are no square Android devices, but you can see that the reason for destroying and re-creating the activity during orientation change is to load alternative resources specific for the new orientation. Since rotating a square device doesn't change the screen dimensions, there is no need to load alternative resources, and therefore, there's no need to destory and re-create an activity. I hope that helps.
I believe the WIMM ONE is the only square screen Android device out there. It has capacitive touch display at 160x160.
Yes, the Motorola Flipout is one.
Currently I have an app which works on Android 1.6 and above, works on QVGA screens upwards. I'd rather not have to rewrite a separate application for Honeycomb and I can't find much help anywhere. Is there an easy way for me to adapt it to work on Android 3.0+ with a proper tablet interface rather than just magnifying my Android-phone interface. I've noticed there is something called fragments, but they seem to involve a major rewrite? Thanks!
As you say, it's all about Fragments. To make a nice app that makes full use of a large screen and of course a small screen the layouts will be different. Fragments help to break up you UI and make it easier to have larger screens use more pieces of your UI (fragments).
Generally it isn't a big change moving from Activities and Views to using Fragments.