Development
-
October 10, 2023

How To Craft Android TV Apps With Jetpack Compose

Jetpack Compose vs Leanback Framework

If you ever ventured into crafting applications for android tv, you’ve inevitably had to deal with the Leanback framework, confronting its capabilities, limitations, and the associated learning curve. However, the introduction of Compose for tv is excellent news. Those unfamiliar with the older framework will find Compose an exhilarating change, especially if tasked with Android TV app development in the future.

Advantages:

  1. Great customization:  Where Leanback often falls short, leaving developers desiring more, Compose excels.
  2. A smaller learning curve: Since is based on Jetpack compose API, developers only need to focus on those new components, which we are going to talk about later in this article.
  3. Effortless Maintenance: As Compose for mobile, the nature of it translates to more efficient and easier maintenance.

However, it is important to note that as of the time of writing, there are two notable disadvantages associated with Compose for TV:

  1. Limited community support for TV-specific APIs.
  2. Most APIs are still experimental.

What's new in Jetpack Compose for TV

Jetpack Compose for TV builds upon the capabilities of Compose for Mobile, by introducing components specifically optimized for TV platforms. One notable addition is the support for D-Pad navigation, which enhances the user experience when interacting with TV applications using a remote control. Since TVs lack touch screens, most rely on up, down, left, right, and select buttons on the remote to navigate the UI. TV UI must provide instant and distinct feedback when buttons are pressed.

The unique navigation experience of a TV app compared to a mobile one has led to the introduction of several new components:

- Immersive list: Enhances user experience by merging a content row with a preview of the chosen item, offering a panoramic content overview.

- Carousels: Showcase a selection of content relevant to the user. A Carousel is made up of several different slides, automatically moving between the different items after a specified amount of time, to engage and captivate the user’s attention.

- Navigation drawer: The Navigation drawers provide a clear and intuitive way to navigate through the app highlighting the primary destinations of our app.

- List: Similar to mobile, lists display item collections. The components optimized for Tv are:

    - TvLazyColumn: as mobile LazyColumn, this component offers a vertical arrangement of items.

    - TvLazyRow: as LazyRow for mobile, allows for a horizontal alignment of items.

- TvLazyVerticalGrid and TvLazyHorizontalGrid cater to grid-based arrangements.

Other components:

- Tabs: Offer an effective and intuitive method for navigating and organizing content within an application across multiple screens as an alternative to the navigation drawer. But also provides a visual representation of the different categories or sections of your app, allowing users to easily switch between them.

- Cards: Specifically for TV offers built-in components to build list cards with distinctive variations such as Standard, Classic, Compact, Wide Standard, and Wide Classic.

- Buttons: Compose for TV modifies existing mobile button designs by introducing the Glow parameter. That defines the shadow to show behind the button taking on three distinct states:

  • Default state
  • Focused
  • Pressed

Furthermore, Compose TV introduces a fresh category of buttons: the WideButton, which has a higher emphasis than other buttons.

To sum up, the new components are:

- Immersive list

- Carousels

- Navigation drawer

- Lists

- Tabs

- Cards

- Buttons

Conclusion

Crafting an Android TV application is embarking on an emotional roller coaster. The journey begins with the realization that you must use an aged framework, one that doesn't has the most favorable reputation, as we examined its drawbacks, the ride is on a downward spiral.

Yet,  just as the descent seemed inevitable, a glimmer of hope emerged on the horizon: Compose for Android TV. This revelation propels you with renewed optimism.

However, the ascent is soon met a twist, Compose for android tv is still in the experimental phase and the transition to full-scale production implementation must wait a little longer.

As we continue on this unpredictable journey as good news we need to tell that in our Android base repository, we have a practical implementation of the majority of these new components presented in this article.