Some of the essential tools and elements to use to develop modern interfaces for our Android apps. Many elements are available to those who want to try their hand at interface design on Android. Various types of layouts, controls, and menus: all have their purpose and respect the rules imposed by the operating system. However, some of these components enrich the application with flexibility and adaptability, two fundamental characteristics of a modern app, especially on Android. The user interface of an application must not base the navigation between its “pages” exclusively on the alternation of Activities. Instead, the building blocks for managing the interaction should be Fragments.
Their main peculiarity is their reusability. They can be placed within an Activity and become part of another, bringing with them all the internal logic of an application screen. Or, as we will see in practice, the same Fragments can be simultaneously part of two different architectures: a tabbed structure and a Viewpager (a container of different panels) navigable by swipe scrolling ). Fragments are mostly logical elements: with their life cycle, they play a “controller” role, a dialogue between the actual logic of the application and the Layout shown. From the point of view of visual elements, a crucial problem immediately comes to mind: the diversity of displays. This aspect must be addressed by distinguishing the two main aspects:
- Size diversity: The same UI may appear suitable for one display and wholly inadequate for others. The well-designed Layout should be optimized for different screens, not just support them. To do this, avoiding fixed sizing in favor of solutions that adapt to the available space is necessary. The first way to do this is to understand the wrap_content and match_parent directives which should be used as much as possible. With these modifiers, an element will get the minimum size to contain what it has inside ( wrap_content) or expand to its container’s borders ( match_parent).
- The fundamental is the Relative Layout. Its “relative” nature allows this type of Layout to adapt as much as possible to the size of the display. It must always be used unless specific needs arise that prevent its adoption;
- density diversity: the dimensions should be explicitly specified as little as possible, as mentioned in the previous point; if necessary, the dp or dip ( Density Independent Pixel ) must be used as the unit of measurement. Never use the pixel or similar units because they do not consider the display’s pixel density.
The structure of an application strongly depends on its purpose. This guide will look at some of the more common application architectures. Once the suitable structure has been chosen, the user interface must be built using some fundamental elements:
- A significant one is the ActionBar, whose use as the backbone of the interface and container of commands to be activated (the actions ) will be explored.
- The Menus are also very important because they play a decisive role in interacting with the user: they allow you to execute commands and request operations that affect the app in general or on a single element.
The menus themselves will be the objects of particular study in the course of this guide. We will see, in particular, the “imperative” role played by its various declinations in elements widely used in applications, such as the NavigationDrawer, the pop-up side menu, and the Contextual Action Bar, a different way to offer the context menu in the form of a temporary ActionBar.
Also Read: Lenovo ThinkVision P27h-20: An Accurate Workmate