Do screen dimensions matter when programming for Android tablet? - screen-orientation

It's my first time programming for anything that isn't a PC. I would assume that things like screen dimensions and orientation would matter on a tablet, but in the bits of basic sample code I've found there hasn't been anything about this. Does rotating and resizing automatically happen? If not, how do I make the app full-screen?

Quick answer: yes android automatically fits your layouts to the devices screen. You can have specific layouts depending on the size and orientation of the devices. Android manages which ones to use and how to handle rotations.
When the tablet is rotated, a configuration changed event is fired. If your application doesn't state that it will personally handle this event then the android framework handles it for you. When the framework handles it, your application is killed and restarted. This allows the application to load a different layout (if you specified a different layout for landscape/portrait). The same thing happens for other configurations changes such as locale and many others.
There are two methods to make an application full screen. The first simply states the application supports a specific dpi. The following code in the Manifest supports all dpis.
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
The second method is to state that the application has been tested for and can support larger screen sizes via the targetSdk. This however, removes any compatibility features that may have existed. For example, I had an application that did some massive processing on the user interface thread, when I added the targetSdkVersion code to make my applications screen larger, the application no longer worked. This was because the targetSdkVersion not only made the screen bigger, it removed compatibility code that allowed the front end thread to do long processes. So that is your warning. Here's the code:
<manifest>
<uses-sdk android:targetSdkVersion="11" />
</manifest>
Note that the target sdk can also be 12. Here's a link to the android version and sdk number.

You can make an activity full screen by setting the theme in the xml or layout designer, for example Theme.Black.NoTitleBar.Fullscreen will give you an activity that is fullscreen.
If you rotate a device then it will use the same layout unless you have defined an alternative layout. I usually start by making a portrait layout then you can simply make a landscape version of the same layout, but for tablet you'll probably want to start landscape since that is the main orientation.
Take a look at this video it covers this and some other handy features of the layout editor:
http://youtu.be/Oq05KqjXTvs
Hope this helps get you started!

Related

Flutter web renders elements on the screen too large

Flutter web seems to render the elements on the screen way too large. Everything, from text, to Containers, to form fields, is massive. It is like everything has been zoomed in. It doesn't look good. I thought setting the visual density of the theme to VisualDensity.compact or VisualDensity.adaptivePlatformDensity would fix it, but it doesn't seem to. Running the app on a very large iPad Pro does not enlarge the elements. Why might this enlargement happen? I work on another Flutter app that is not enlarged on web and am unsure of what the key difference is that is causing the different rendering behaviour.
This ended up being due to setting my mac display to "Scaled" with "larger text" in system preferences. It seemed to affect the web version and not the mobile simulators; I guess because the simulators are not under the mac display settings; they are their own device.
The fix was to set it to "Default for display":

Non-4-inch apps top-aligned when new splash included

Apple is now requiring a retina and 4-inch display Splash page (i.e. the "Default-568h#2x.png") for all apps to be submitted, which is fine. However, when I include that and then do another build, once I get into the app, instead of it being centered with dark on the top and bottom (as it was before), is now top-aligned on the screen with 2x the blank space on the bottom.. which looks really unprofessional.
Is there any way via our configuration to tell the OS to go back to centering the app, despite that it has the now-required 4" Splash page included? Ideally I'd like to be able to do this without updating every single IB view in the app to center it manually, as I feel the OS should still be able to do this somehow via configuration.
FYI, answers that say "update your entire app for 4"!" are unacceptable. There are clients who don't yet have a creative budget for this but still want to keep their existing app looking decent in the store. If it's not possible, then it's not possible, but that is why I'm asking the question.
Thanks in advance for any assistance on this, and my apologies if this has already been asked.
As of May 1 if your submitting this app to the app store you will be required to support both retina display's, and the new 4" screen size.
https://developer.apple.com/news/index.php?id=3212013b
You misunderstand. As of now, you must fully support the full 4" screen of the iPhone 5 and 5th gen iPod touch, in addition to retina and non-retina devices.
By adding the "Default-568h#2x.png" launch image (it is not a splash screen) you are telling the OS that your app supports the 4" screen.
You must update your app to fill the screen. There are countless existing posts about how to do that. There is no way around this. It is 100% required - no exception from Apple.
BTW - Apple announced this requirement on March 21st. Every registered iOS developer was notified of the requirement.
It isn't possible to do what you're asking with a single setting. Your best options are a bit of code that runs when you load a view to change the origin.y position, or, go through the XIB files and update the autoresizing rules so that the views expand to fill the space. You might not have budget to update the graphics resources in the app but you should be able to spend the small amount of time required on autoresizing.
The caveat to 'small amount of time' may apply to you - if you explicitly set the size of all of your views in code you've made life painful for yourself.

Safari: how to size the browser for the iPhone size (or some other solution)?

I am coding a web app for an iPhone and I'm wondering how best to use Safari to develop for the iPhone, the main problem being that I've got is that Safari apparently cannot be resized to the narrow 320 pixels of width. How can I do that?
Any other tips and tricks?
If you are looking for an environment to test, Ripple emulator seems a nice option.
I had the same problem and solved it quickly and simply by using a 320x480-sized iframe. Additionally, I added options to change the size (iPhone portrait, landscape, iPad, status bar or not, ...) and presto! an iPhone “simulator”!
Edit: that also allows the use of the Web Developer tools, they're invaluable in Safari or Chrome (I prefer to use the latter, but both are Webkit-powered).
The absolute best way is to use a real device - iPhone or iPod touch - so you get a proper feel for how the device responds. If you're doing hefty animations, for example, testing on a desktop computer may leave you scrambling once you realize the entire page lags horribly on a real device the day before launch.
Barring that, you should use the iOS Simulator that comes with the xCode iOS SDK.
You can use a browser extention or plug-in. For Safari there is ResponsiveResize for instance. You can donwload it here. It allows you to use a predefined browser size, or use any custom size you'd like.

iPhone & iPad Apps Launch Images

Preamble: This is intended to be be a canonical question (and answer) on iOS Apps launch images (aka Default.png).
Questions
What is the best way to set the Default.png; Manually in the Info.plist or using Xcode (supported in xcode-4 only, I think)
Does the iPhone auto-rotate the Default.png depending on the device orientation?
What effect does the UIInterfaceOrientation (Initial interface orientation) key in the Info.plist have?
Does UISupportedInterfaceOrientations and UISupportedInterfaceOrientations~ipad have any effect on displaying the Default.png
Can I set different Default.png for the iPad using these file names?:
Default-Portrait.png
Default-PortraitUpsideDown.png
Default-Landscape.png
Default-LandscapeLeft.png
Default-LandscapeRight.png
Are there iPhone equivalents (see 3)
Is there any Apple documentation that covers all aspects of "Launch Images"? If so, where?
NB: It seems the usage of launch
images changes quite frequently
between SDK releases, please indicate
in your answers what version you are
talking about
5) Is there any Apple documentation that covers all aspects of "Launch Images"? If so, where?
There's something here:
Supply a launch image to improve user experience.
Avoid using it as an opportunity to
provide:
An “application entry experience,” such as a splash screen
An About window
Branding elements, unless they are a static part of your application’s
first screen
Partial answers based on latest iPhone iOS
Manually in the Info.plist or using Xcode (supported in xcode-4 only, I think)
These two methods are equivalent. Xcode merely presents a convenience editor UI for the info.plist. There is no other way to specify the launch image (available to 3rd party developers) than setting it in info.plist.
Does the iPhone auto-rotate the Default.png depending on the device orientation?
No. but as Springoard does not support upside down, it is unlikely that any portrait apps are launched upside down.
What effect does the UIInterfaceOrientation (Initial interface orientation) key in the Info.plist have?
None
Does UISupportedInterfaceOrientations and UISupportedInterfaceOrientations~ipad have any effect on displaying the Default.png
No.
In my experience, the simplest approach with the easiest maintenance is to simply follow Apple's conventions when naming your launch image files. If you carefully read and follow those naming conventions, everything else becomes automatic. Automated features include:
Choosing different launch image files for different device screens.
Handling the new taller screen found on current iPhone 5/5S & iPod touch.
Handling Retina screens.
Handling device orientation (Portrait vs Landscape) on iPad. (handhelds have only Portrait)
Displaying thumbnails in Xcode 4
If you:
Create image files with the correct resolution (carefully read the doc, as resolutions are not what you might expect)
Follow the naming rules documented by Apple
Place the files at the top level of your app bundle†
…then:
Thumbnails of the images will automatically appear within project settings of Xcode 4.
Your launch images will automatically be used on devices as well as the iOS Simulator.
By following the naming conventions, you need not:
Select images manually in the Xcode project settings
Edit any info-plist
The naming conventions work at least in iOS 5, 6, and 7. I believe they also work in earlier versions as well.
†Image files should not be nested in any physical folder. After adding them to Xcode, you may group them into a virtual folder within Xcode's project listing to avoid visual clutter.
Tip: To verify which image is being used, alter the image itself to display the file name as part of the image. Make a backup of your images first, of course.

What's the easiest way to change an iPhone app into an iPad app?

I have an iPhone app that I want to change into an iPad app. I do not want to make it universal. The result should be an iPad only app. The main problem I see is converting all of my .xib files. I realize that I will have to change some things around manually, but I would like as much as possible (including all of the painstakingly made connections in IB) to carry over. Also, if there are unlikely places where I need to change settings, please give me a hint to that as well. Thanks!
Xcode has a convert option. It gives you the choice between a new app or a universal one.
This will convert all your NIBs, but quite how useful that is will depend on how thorough you've been with the sizing options in Interface Builder. For me is mostly worked. A couple of minor tweaks for a couple of views and a complete rewrite for some others.
Of course you'll also have to work with view controllers that "manually" build the view.
The gotchas I found were around orientations (iPad apps should work in all four orientations) and with the screen size. There are also some oddities with the keyboard and modal views if you have any of those (there are a few kinds of modal view, and the keyboard does not always dismiss). As ever when you're making automated changes, testing is key.
The full process took me a lot longer than I was expecting.
Few thoughts for changing iPhone app to iPad app.
Xcode has the provision to change the current iPhone app to iPad app by using "Upgrade current target for iPad" menu command.
http://www.enscand.com/roller/enscand/entry/ready_for_ipad
resize all current view to the ipad size 768*1024(portrait) and then resize all the subviews respectively. the connections doesn't get lost by doing this.