Skip to main content

Posts

Showing posts from February, 2022

Fragments In Android Kotlin

Fragments Represent Reusable portion of your apps UI  Fragments are used to define and manage UI of a single screen or portion of screen. Fragments has it's own layout , Life cycle and can handle input events Fragments can not exist on its own it must be hosted by an Activity or another Fragment Activities act as a frame that contains the fragment .Each fragment operates like a view in the activity but it has  has it's own layout , Life cycle and can handle input events. Activities are ideal place to put global elements around your app's UI like Navigation Drawer, Toolbar , Bottom Navigation and fragments are better suited to define UI of single screen or portion of screen. You can use multiple Fragments with single Activity ,  this gives more modularity and reusability to our code. Add the following dependency in your app level build.gradle file to use fragments implementation "androidx.fragment:fragment-ktx:1.3.6" Now create a new fragment  package com.arun.and...