Display Orientation
Adapting To Display Orientation
One of the key features of modern smartphones is their ability to switch screen orientation, and Android is no exception. Android supports two screen orientations: portrait and landscape. By default,when you change the display orientation of your Android device, the current activity that is displayed will automatically redraw its content in the new orientation. This is because the onCreate() event of the activity is fi red whenever there is a change in display orientation.
Display Orientation
NOTE:- When you change the orientation of your Android device, your current activity is actually destroyed and then re-created.However, when the views are redrawn, they may be drawn in their original locations (depending on the layout selected). Figure shows one of the examples illustrated earlier displayed in both portrait and landscape mode.
Display Orientation
As you can observe in landscape mode, a lot of empty space on the right of the screen could be used.Furthermore, any additional views at the bottom of the screen would be hidden when the screen orientation is set to landscape.
Display Orientation
In general, you can employ two techniques to handle changes in screen orientation:➤ Anchoring — The easiest way is to “anchor” your views to the four edges of the screen. When the screen orientation changes, the views can anchor neatly to the edges.
➤ Resizing and repositioning — Whereas anchoring and centralizing are simple techniques to ensure that views can handle changes in screen orientation, the ultimate technique is resizing
each and every view according to the current screen orientation.