‫Welcome back to better understand the fragments in Android, let's move to Android Studio and create
‫a new project Empty Views Activity, and I'll name this project as a fragments app.
‫Select Kotlin and click finish and to create your fragment.
‫Here in the package I'll create a new note activity.
‫I'm going to create a new fragment and you can select from a bunch of fragment types, but I prefer
‫using the fragment blank here.
‫I'll name it as fragment one.
‫The layout name would be fragment underscore one dot XML and the source language will be Kotlin.
‫Click finish.
‫And here we go.
‫Don't afraid.
‫From this code I'm going to delete the unnecessary code.
‫I'll keep the Oncreate view method.
‫As I told you before, it's very important method for the friends in Android development.
‫A fragment is a modular and reusable component that represents a portion of a user interface or behavior
‫within an activity.
‫Fragments were introduced to facilitate the creation of flexible and responsive user interfaces for
‫both smartphones and tablets.
‫They are a part of the Android API since Android three API level 11, and are a crucial part of the
‫Android framework.
‫Fragments encapsulate a portion of UI and behavior, allowing developers to break down the user interface
‫into smaller, more manageable pieces, and the fragments can be reused across multiple activities.
‫This promotes code reusability and helps maintain a consistent user interface across different parts
‫of an application.
‫Let's move to the layout of the fragment.
‫Underscore one dot XML file.
‫I'll go to the split mode and here we can see it's a frame layout containing a text view.
‫A frame layout is a type of layout that acts as a simple container for holding a single fragment.
‫It's often used in conjunction with the fragment class to organize and manage UI components within an
‫activity.
‫In the next videos, I'm going to talk about the frame layout in deep details, but I want from you
‫to understand that the frame layout used for holding a single fragment, and this is the single fragment,
‫which is the fragment underscore one.
‫Here I'll increase the size of the text view.
‫I'll make it as 48 dpi and the color black and the text the first fragment.
‫So this is how we create fragments in Android.
‫I'm going to create another fragment here in the same package in the same way new fragment blank fragment.
‫And here I name it as fragment two.
‫The fragment layout fragment underscore two and the source language is Kotlin.
‫Click finish.
‫And here we go.
‫In the same way I'm going to delete this unnecessary code.
‫And I'm going to keep the Oncreate view method.
‫This is fragment number two.
‫Go to the layout here.
‫Go to split mode and I'll change this layout.
‫And I'm going to edit text view here size 38 SP and the text the second fragment.
‫Also to distinguish between these fragments I'm going to use a background color and I paste this color.
‫This is the green.
‫And for the fragment one I'm going to use the background.
‫And I'll paste this code.
‫And this is good okay.
‫So this is our first fragment layout.
‫And this is our second fragment layout.
‫This is how we create fragments in Android.