Basic Views

What is a view? A view is an object whose class is android.view.View. It is a structure of data and properties, the data of the layer, the specific information of the rectangular area of ​​the screen and allows the design.Views have a lot of properties, but I’ll add the basic ones, there is other to change the colour, background, size etc.

Let start with some of the views of android:

  • Button: A Button type control is the most basic button that we can use and usually contains a simple text.

  • A control of type ToggleButton is a type of button that can remain in two possible states, pressed or not-presses so that’s why we need to declare the properties of textOn and TextOff If we want two different text in the button.

  • Image Button: In a control of type ImageButton we can define an image to be displayed instead of a text, for which we must assign the android property: src. Normally we will assign this property with the descriptor of some resource that we have included in the / res / drawable folders this time I choose a default image from the android project.

  • ImageView: The ImageView control allows displaying images in the application. The most interesting property is android: src, which allows you to indicate the image to be displayed. Again, the normal thing will be to indicate as the origin of the image the identifier of a resource of our folder / res / drawable

  • TextView: The TextView control is another classic in the programming of GUIs, text labels, and is used to display a certain text to the user. As in the case of buttons, the text of the control is established by the android: text property.

  • EditText: The EditText control is the text editing component provided by the Android platform. It allows the introduction and editing of text by the user, so at design time the most interesting property to establish, in addition to its position / size and format, is the text to be displayed, android attribute: text. Of course, if we do not want the text box to be initialized with no text, it is not necessary to include this property in the XML layout. What we must establish will be the android property: inputType. This property indicates the type of content that will be entered in the text box, such as an email address, phone number, web or just plain text.

  • CheckBox: A checkbox control is usually used to mark or unmark options in an application, and Android is represented by the class of the same name, CheckBox. The way to define it in our interface and the methods available to manipulate them from our code are analogous to those already commented for the ToggleButton control.

  • Radio buttons: Like the checkbox controls, a radio button can be marked or unmarked, but in this case they are usually used within a group of options where one, and only one, of them must be marked, that is, if the options, the one that was previously active will be automatically unchecked. You need to regroup all these button in a RadioGroup to make it know the group.