‫Welcome back.
‫In this video, we'll learn about the first widget in Android studio called the Text View.
‫Text view is a fundamental UI element that displays text on the screen.
‫It's part of Android widget framework and is commonly used to present a static or dynamic text content
‫to the user.
‫Text view is versatile and supports various formatting options such as colors, size, style alignment
‫and more.
‫Let's create our very first text view.
‫Let's start with the text view.
‫Or you can simply drag and drop from the palette.
‫If you switch to the design mode, you search for text view here and drag and drop a text view.
‫You can use this method or you can programmatically create a text view by typing the tag text view,
‫then moving down.
‫You can see these two attributes are mandatory to be mentioned.
‫The layout width and the layout height.
‫Again, as a quick recap, attributes are properties that can set for a text view to customize its appearance
‫and behavior.
‫These attributes are defined in XML layout files that can also be modified programmatically in Java
‫or Kotlin code.
‫Let's learn about some of commonly used attributes of text view layout width.
‫I'll set it for matchparent later on I'll talk about layout, width and height.
‫I'll set wrapcontent for the height and matchparent for the width.
‫You can see that a text view appears here.
‫Now let's learn about the text content attributes.
‫First of all, I'll introduce Android text in order to define an attribute, you start by Android column
‫and here are a lot of attributes you can see and you can define them from here to the right, we have
‫an attribute panel.
‫You can set them either programmatically or from the visual editor Android text equal to.
‫Hello my friends.
‫You can see the text view appears here.
‫Now let's customize the size so set by text size equal 32 SP, SP and DPI are units in Android to detect
‫the size according to the pixels density pixels or the SP android text color.
‫I'll define for example red.
‫So I put here the red.
‫This is the hex code for the red.
‫Or you can simply.
‫Change it by clicking on this color.
‫I'll change it to green.
‫You can see the changes take place.
‫As mentioned before, you can set the attributes here for the text view from this attributes panel to
‫the right.
‫Okay.
‫You can see there is a text color attribute here.
‫I can change it to the.
‫Blue, for example.
‫Blue color.
‫And you can see either I can change from here or I can change from the code.
‫The text style sets the style of the text.
‫These are normal, bold or italic.
‫I'll make it as bold.
‫You can see I'm changing the color, the content of the text.
‫Gravity sets the text alignment.
‫Either I can make it as center start and end, etcetera.
‫These are attributes specific for the text content.
‫There are other attributes.
‫For example the text appearance.
‫I can use typeface in order to set the typeface or the font of the text.
‫For example, I'll use serif.
‫You can see that font of the text is changed.
‫I can use text all caps sets.
‫Whether the text should be displayed in all capital letters I'll use true.
‫You can see that the text is changed.
‫Padding and margins.
‫I can use padding to set the internal padding of the text view.
‫So for example, padding equal 20 deep.
‫Also there are specific padding attributes.
‫So for example, padding button and horizontal left, right and so on.
‫So you can specify padding.
‫Right ten DPI.
‫Okay.
‫Padding here for from all sides I can set margin sets the external margin of the text view, for example,
‫margin layout margin, I'll specify it as 20 DPI.
‫I'll decrease the size of the text too to allow the margin and padding to be displayed.
‫I'll make 20 SPP and if I remove padding and margin, you can see that the text will change.
‫If I add padding, you can see the changes will take place and if I use the margin, you can see I am
‫margining it from the left, right, top and bottom.
‫Also, I can edit the background and the border.
‫I can use Android background sets, the background color or drawable for the text view I can use from
‫the colors here, or I can specify the color hex code.
‫What I can specify another color, for example green.
‫This is the hex code for the green color.
‫Also, I can edit the text handling so I can set the type of the text input.
‫Expected input type will specify if it is either a text date date nine a time none number number, decimal,
‫password and phone, email and so on.
‫I'll keep it as text.