‫Welcome back.
‫In this video, we'll learn about the second widget, which is the edit text.
‫Edit Text is a UI element that allows users to input text.
‫It's an editable field where users can enter text using the onscreen keyboard or other input methods.
‫Edit Text is one of the fundamental input controls in Android and is commonly used in forums, search
‫bars and other scenarios where user input is required.
‫Let's create our edit text starting by, edit, text, tag, edit or simply by dragging and dropping
‫from the design mode and edit text.
‫You can search for edit text and you can see a lot of edit text forms.
‫I can drag and drop a plain text or password or something from the edit text.
‫I'll start with the width as matchparent to match the parent view the parent layout, which is the constraint
‫layout and that forms the whole layout.
‫Later on we'll talk about the layouts and the constraint layout.
‫The width will be parent, the height will be wrapcontent.
‫You can see there is an edit text formed here.
‫Now let's start with the text content and input type.
‫We start by text.
‫I can define a text for it sets the initial text content for the edit text.
‫For example, enter your name.
‫This is an initial text, not a hint.
‫I can specify a hint like for example.
‫Hint enter your name.
‫What's the difference here?
‫We set the initial content, the initial text content of the edit text while here sets a hint text that
‫appears when the edit text is empty, providing a visual clue to users about what they should enter.
‫So whenever the user click on the edit text they enter your name hint will disappear.
‫The input type.
‫I can specify here the type of text input expected like text number, password, email or other forms.
‫Text color sets.
‫The color of the text I can set it, for example black, or you can enter the hex code for the black
‫or other colors like blue.
‫The text size sets the style of the text style, text style, bold size.
‫It increased in size.
‫I can set the maximum number of characters allowed in the edit text by using the maximum length attribute.
‫And of course I can set the padding and the margin attributes, setting the internal padding for the
‫edit text and sets the external margin of the edit text respectively.
‫Margin equal 20 DPI and the most important attribute that every widget should declare is the ID.
‫The ID is the unique identifier for the widget.
‫I can start by ID, android id at plus id slash and I'll name it as edit text in order to get the input
‫text from the user and use it in your application.
‫I need to access the content of the edit text and handle the user input programmatically.
‫Let's move to the main activity.
‫Let's initialize our edit text and get the input text from it.
‫Here.
‫I'll start by edit, text, my edit, text and alt here alt plus enter to import the package of the
‫edit text from the Android equal to find a view by ID this magical method that finds and link my edit
‫text variable to this widget that I declared in the XML layout.
‫So I am linking my edit text variable to this edit text widget specifying here the id edit text.
‫Now I'll get the input text from the edit text and store it inside a string variable.
‫So I'll start by string input text equal to my edit text dot get text.
‫You can see this magical method that allows us to get the input from the user and transform it into
‫a string.
‫So I'm getting the input text that the user enters from the edit text and store it inside the input
‫text.