-->

Encrypting your link and protect the link from viruses, malware, thief, etc! Made your link safe to visit.

View Class

In the last article, I talked about the layouts in Android and a little bit about the Widgets. Behind the scenes, they are all subclass of the 'android.view.View' class. Some of them might not be the direct subclass of the View class but they are present in the hierarchy.

Layouts are a direct subclass of 'android.view.ViewGroup' class. A view group is a type of view that can contain other views.

View Class


Here are some of the View methods that can be used in our activity code. There are common for all widgets and layouts.

1)getId()

2)getHeight()

3)getWidth()

4)setVisibility(int)

5)findViewByInd(int)

6)isClickable()

7)isFocused()

8)requestFocus()

Other functionality of View class:

1)Getting and Setting Properties: We can set and get the properties in our activity code. As an example, we can change the text of the textview.

Ex: textView.setText("Hello World");

2)Size and position: We can specify the width and height of the view. You can retrieve the position and its actual size on the screen.

3)Focus Handling: Android handles how the focus moves depending on what the user does. This includes responding to any views that are hidden, removed, or made visible.

4)Event handling and listeners:
We can create listeners for the view so that they can react to things happening in the view. As an example,a button reacts on clicking of it.

ST

Social

Recent

⬇⬇Get Your Link⬇⬇