let’s make something together

Give us a call or drop by anytime, we endeavour to answer all enquiries within 24 hours on business days.

Find us

Unit P Hunting Gate, East Portway, Andover, Hampshire, SP10 3ER, United Kingdom (UK)

Email us

[email protected]

Phone support

Phone: +44 207 993 2188

Facebook’s Open Source Litho for Android: Declarative UI Framework

  • By Hidden Brains
  • June 7, 2017
  • 806 Views

Facebook’s Open Source Litho

User Interface (UI) is quite an essential component of mobile app. Facebook’s Litho is an open source declarative framework focused on creating user interface for Android. In fact, Facebook’s Android app uses the same interface in the latest version that we are using now.

Facebook Inc. came up with an announcement of this open source Litho framework in its F8 Developer Conference. Following is a list of highlighting features of Facebook’s Litho framework:

1. Declarative Nature of Litho

Litho is based on declarative API for defining UI components. With the help of immutable inputs, users can define their own UI. Immutable elements allow for rendering of layout in a different thread, which is further passed on to UI thread for actual display on screen. Litho uses highly optimized code, which is simple to understand and maintain.

2. Flatter View of Hierarchies

Flatter View of Hierarchies
Image courtesy: fblitho
litho framework
Image courtesy: fblitho

Litho provides flatter view of hierarchies for good readability and better scrolling performance. This further enables spotting out mistakes in coding quite easily as everything is properly grouped together. Revising UI programs is simpler with better visibility of code lines and text optimizations.

3. Asynchronous Layout

Facebook Litho
Image courtesy fblitho

Litho utilizes ‘Yoga’, a cross platform layout engine, for layout of different components. With Yoga for Litho, processes can be managed both synchronously as well as asynchronously. Developing UI of Android apps is much simpler when coding is reflected in layout well ahead of time. Litho does just the same by blocking UI thread of traditional Android View system. When the visual representation of UI is available, it becomes simpler to program UI for Android apps.

4. Fine-Grained Recycling

Recycling of multimedia such as image, video or even text enables coupling of these elements for future use. With this, there is no need to rewrite code for integrating same elements in the UI. Lesser the code, faster is the performance. Litho allows reusing of components, once it disappears from the current one.

As per Facebook, Litho is 35% faster than RecyclerView for scrolling surfaces. This framework is currently in use for several Android apps including Workplace, Facebook, Facebook Messenger and Facebook Lite. Some important elements of Litho are as listed down below:

  • 300 Java classes & interfaces
  • Unit Testing
  • Event handling
  • Custom layouts

Developers are exposing the potential of this open source framework and leveraging it to their benefit.

Leave a Reply

Your email address will not be published. Required fields are marked *