Sunday , November 28 2021

Android App User Interface Basics – Android UI introduction

Android App User Interface Basics – Android UI introduction – Till the last chapter, we have tried to understand in detail many of the basic concepts related to Android Development and have discussed in depth about various parts and lifecycle of an Android App using some UI Elements i.e. User Interface Controls.

Android App User Interface Basics - Android UI introduction

In this chapter also we will know some more things related to Android Development, but in this chapter, our basic objective will be related to developing an Android App User Interface because most of the Android App will have some kind of User Interface. And Android Apps has a complete Specify System of UI Controls and related Event Handling, which it is not possible to develop Android App without understanding it properly.

Developing UI for Android App is somewhat easy as the Android Framework is the most modern framework till date, which has been tried to be the simplest for developers, so that in the shortest time Best Possible Android App developed Can go

The UI of Android App is also easy to develop because very few UI controls are provided for Android App by the Android SDK and fewer UI Controls are provided, because generally only for small screen devices like Android Apps Mobile. Are created and these small screen devices do not require very complex types of UI Controls. That is why any Android developer can remember almost all the UI Controls and their features provided by Android SDK very easily.

Also, the Android UI also takes care that the developer has to write at least a number of codes to meet a specific requirement. Rather, the Android system handles most of the complexities related to the UI at its own level, so that the App Developer can concentrate on the functionalities associated with their Android App in place of Coding, which it wants to achieve with that Android App.

UI Class Hierarchy

Like any other SDK, Android SDK provides GUI Controls like Button, TextBox, EditBox etc. But the Android SDK provides all these controls through two main classes android.view.View and android.view.ViewGroup.

Both the View and ViewGroup Classes in the Android SDK are the main Core Classes providing controls related to the UI of Android App. The View Class represents a General Purpose View Object, which is why in the previous chapter we set a reference of a TextView Control as a Parameter by displaying it as an Associated First Screen through the Codes as set in the setContentView () method. Had given:

TextView tvWithoutView = new TextView (this);
this.setContentView (tvWithoutView);

tvWithoutView.setText (“Aha! No need of activity_main.xml”);

This can be possible to do because according to the Inheritance Concepts of Java, any Base Class can reference and hold not only the objects of the same Base Class but also the Objects of any Derived Class and setContentView () method as Parameter. I always need the Object Reference of a View Class, so when in the above code we pass the object of a TextView Control as a Parameter in the setContentView () method, then this method outputs the Text of the TextView Control without any problem. Display in it because every UI Control in Android SDK is derive from View Class itself and TextView Control is also Derived UI Control from same View Class.

Actually android.view.View Class itself derived from java.lang.Object Class, so all members (Data Members and Member Functions) of java.lang.Object Class are inherited, whereas android.view.ViewGroup Class itself android. view.View is Derived from Class, so it has all the Members Inherited of android.view.View Class.

So for any Android App, the View Class is actually the Highest Level Generic Class, while the ViewGroup Class is a Specialized Class and Specialized Class always performs more Special Task.

View Objects are created by the View Class. While we can also create other Lower Level or more customized Specialized Classes by Inherit this View Class and ViewGroup Class is a similar Specialized Class, which inherit the characteristics of its Super Class View.

Therefore, the Basic Screen Layout of any Android App is controlled by the View Class itself, which holds more Complex Data Structures by which the View’s Content and Layout Parameter Represent for a Specific Screen Size of a Device .

That is, how our Android App will display on the Specific Screen Size of a Specific Device, this view is fully controlled by the View Class and without our knowledge it controls itself automatically, for which we as an App Developer Nothing has to be done.

The various UI Controls are extended by the View class of the Android SDK itself and the ViewGroup is also one of them, which is why we in the setContentView () method can also view any View ie Layout related XML Resource File such as activity_main.xml. Specify as Parameter via layout.activity_main Statement, which represents the Layout View Hierarchy associated with our Activity.

Because when Android App Run happens, each XML resource and the XML markups specified in them are internally converted to Java Codes and then those parsed Java Codes are executed by the Android Platform itself.

That is, when an Android App is run, all its XML files are parsing based on the XML Specification of the XML Codes, which results in the creation of a Java Class File and the same Java Class File is run by the Android Platform. That is why we can do all the work related to Layout of our Android App and User Interface through XML Codes of XML File, directly through Java Codes.

Although ViewGroup itself is Extended from View Class, there are many other Classes Derived from it, also known as Layouts. That is, ViewGroup Class is actually the Base Class of various Layout Classes related to managing different types of Layouts of an Android App.

If you have ever created a GUI using Java’s AWT or SWING Package, you can easily understand that just like AWT / SWING, the Android SDK also follows the Container Concept for UI Layouts and ViewGroup as a type Container is the function of holding other UI Controls or Containers. That’s why different UI Controls of any Android App are always held in some container and the entire layout is always displayed in the Output after defining it inside that Container.

If we understand this in the context of our Android App, then the activity_main.xml file related to our Android App is a container of the Visual User Interface Controls of our Activity, including Positioning, Sizing and Orientation of various UI Controls of our Android App. Specify is done and the same Layout File is loaded into memory by the setContentView (R.layout.activity_main) method, which is displayed as an Output Screen related to the Activity.

There are several ways we can use to create a UI for an Android App. We can create the entire UI directly in the Activity File through Java Codes. We can also define the UI as an XML file and we can also mix these two methods together. That is, you can define the UI through XML file and then change, modify or update them through Java Codes as per the need.

But before we go further, it is necessary to understand some terms like View, Widget, Control, Container and Layout properly, so that there is no confusion of any kind when used in subsequent chapters.

View, Widget and Control

All three represent some UI element. Button, TextView, List, Grid, Window, Dialog Box, etc. are all examples of this and in simplest terms, these three can be used interchangeably for each other.

That is, whether we say View, Widget or Control, all three means that we are talking in terms of a User Interface Element and all these are objects of a class derived from View Class.

Container

As we said earlier, this is also a kind of View, but it is a View that works to container any other UI View or Container View inside Hold, that’s why it is also called Container View. It is said. For example, Grid View is a type of container that keeps cells containerized.

Layout

It is a visual arrangement of other Containers and Views and can container other Layouts. We will learn more about this in detail because it is one of the most important part of the GUI of any Android App.

Generally, all View Classes derived from ViewGroup Class represent only one type of container and the Layout View is also a type of container. Therefore we can call the object of any class derived from the ViewGroup class.

Read More – Advantages of Object Oriented Programming Language in Java

About dmtechnolab

Check Also

Simplified Coding

Android Espresso Tutorial – Testing Fragment in Isolation – Android Coding by DMTechnolab

Welcome to another tutorial in the Android test series. And this post is called Android …

Leave a Reply

Your email address will not be published. Required fields are marked *