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?
Share
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.
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:
Note that the target sdk can also be 12. Here’s a link to the android version and sdk number.