Understand How View Renders in Android
Performance-optimization tips for apps while rendering the views
In this article, we’re going to see an overview of how the view we created in XML gets rendered on the screen in pixels.
Making a great-performing app is only possible by knowing what’s going under the hood. If you don’t know what the hardware is doing, you have a chance of using it poorly. Before exploring rendering, let’s learn the basics regarding the life cycle of a view.
Life Cycle of a View
If you have an idea of the life cycle of a view, you can skip this section.
Many of us aren’t aware views have a life cycle, but it’s very important to know the life cycle of a view while building custom views and better-performing apps. Please check out the image below.
Each method of the view has a specific purpose to serve. Let’s dive into the details of a few methods that are required to know for now. onMeasure()
is a method called to determine the size requirements for this view and all of its children. onLayout()
is a method called when this view should assign a size…