Breaking News Layout
Explore how to design the Breaking News layout for an Android app using Kotlin. Learn to replace boilerplate code with modern fragment lifecycle methods, implement RecyclerView for efficient data display, and add a ProgressBar to indicate pagination loading. Understand the use of FrameLayout to layer views and employ design tools for layout preview.
We'll cover the following...
The BreakingNewsFragment class
Create a new empty fragment and name it BreakingNewsFragment, and the layout will be created automatically.We’ll need to make some changes to the class file to reduce some boilerplate code. Below is the initial class that will be created before we start making changes.
When we create a fragment, it comes with unnecessary boilerplate code that we don’t need. For the sake of comprehension, we’ll change some parts of the code.
Cleaning up our code
Before androidx, we were using the onCreateView for initialization to inflate our views. But ...