How to support both landscape & portrait orientation for both phone & tablet?
You know, Android runs on a variety of devices, both phone & tablet which have different screen sizes and resolutions. So it’s important to an App developer to build a reusable, flexible and easy-to-modify UI.
We also have many methods to achieve that goal,
use configuration qualifiers
- provide different layouts for different screen sizes;
- provide different bitmap drawables for different screen densities;
RecyclerView
Just change the layout manager to show list items in a horizontal list layout, or a vertical list layout, or a grid layout.
Fragment
Fragments make implementing this functionality easy. The list of emails would exist in one fragment, and the detail view for an email would exist in another fragment. Depending on the device size, our activity will decide to show either one or both of these fragments.
The beauty of fragments here is that we do not have to modify either of these Fragment classes for this to happen. Fragments are reusable components of our application that can be presented to the user in any number of ways.
include
reusable