The Navigation Drawer is a layout that can be seen in certain applications, that consists of some other activity shortcuts (Intents). This drawer generally can be seen at the left edge of the screen, which is by default. A Button to access the Navigation Drawer is by default provided at the action bar.
So now the question is why is it is necessary to align the Navigation Drawer and its elements towards the left or right of the screen. It is necessary because a screen can represent multiple layouts at a time. To keep all these elements fixed at desired positions, and sizes, each and every entity of these elements must be initialized. Though it is not necessary to initiate these entities in applications representing a single layout, it is always a better practice to initiate all the entities. In view of generating different styling for an application, one would like to implement a drawer toward the right of the screen with elements aligned towards left and other possible versions. Through this article, we want to extend the implementation of a Navigation Drawer and align it and its elements respectively.
When the setup is ready, go to the activity_main.xml file, which represents the UI of the project. Below is the code for the activity_main.xml file for different cases. Note that we are going to modify only the activity_main.xml file in each case.
Align Navigation Drawer towards the Left of the screen:
Please Login to comment...