Member-only story

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 and position to all of its children. onDraw() is called when the view is ready to render its content.

I’m not going to go into detail about every method. For more details, check out this article.

Rasterization

Rasterization i a process of taking some high-level objects like strings, buttons, or shapes and turning them into pixels in the texture on our screen. Rasterisation is a very time-consuming process. So GPU (Graphics Processing Unit) comes into the play to accelerate the rasterization process. GPU is designed in a way to use only specific types like polygons, textures, etc.

CPU is responsible for feeding the content to the GPU before it can draw anything to your screen.

--

--

Satya Pavan Kantamani
Satya Pavan Kantamani

Written by Satya Pavan Kantamani

Android Dev, Interested in Traveling, App development. Based in Hyderabad, India. Catch me at https://about.me/satyapavankumar

Responses (5)

Write a response