Author: admin
-
A Jetpack Compose ViewModel Tutorial
As outlined in the previous chapter, we use ViewModels to separate an activity’s data and associated logic from the code responsible for rendering the user interface. Having covered the theory of modern Android app architecture, this chapter will create an example project demonstrating the use of a ViewModel within an example project. About the project…
-
Working with ViewModels in Jetpack Compose
Until a few years ago, Google did not recommend a specific approach to building Android apps other than to provide tools and development kits while letting developers decide what worked best for a particular project or individual programming style. That changed in 2017 with the introduction of the Android Architecture Components which became part of…
-
Jetpack Compose Canvas Graphics Drawing Tutorial
In this chapter, we will be introducing 2D graphics drawing using the Compose Canvas component. As we explore the capabilities of Canvas it will quickly become clear that, as with just about everything else in Compose, impressive results can typically be achieved with just a few lines of code. Introducing the Canvas component The Canvas…
-
Jetpack Compose State-Driven Animation
The previous chapter focused on using animation when hiding and showing user interface components. In this chapter, we will turn our attention to state-driven animation. The features of the Compose Animation API allow a variety of animation effects to be performed based on the change of state from one value to another. This includes animations…
-
Jetpack Compose Visibility Animation Tutorial
For adding animation effects to user interfaces, Jetpack Compose includes the Animation API. The Animation API consists of classes and functions that provide a wide range of animation options that can be added to your apps with relative ease. In this chapter, we will explore the use of animation when hiding and showing user interface…
-
A Jetpack Compose VerticalPager and HorizontalPager Example
The Compose Pager composables allow users to page through content using horizontal and vertical swiping gestures. Paging may also be implemented programmatically, for example, by adding previous and next buttons to the layout. This chapter introduces the VerticalPager and HorizontalPager composables and explores some configuration options before creating an example project to show paging in…
-
A Compose Lazy Staggered Grid Tutorial
The chapter Jetpack Compose Lists and Grids introduced the horizontal and vertical lazy grid composables and demonstrated how they could be used to organize items in rows and columns. However, a limitation of these layouts is that the grid cells are the same size. While this may be the desired behavior for many grid implementations,…
-
Jetpack Compose Sticky Headers and Scroll Detection
In the previous chapter, we created a project that makes use of the LazyColumn layout to display a list of Card components containing images and text. The project also implemented clickable list items which display a message when tapped. This chapter will extend the project both to include sticky header support and to use scroll…
-
A Jetpack Compose Lazy List Tutorial
Although the creation of lists using the standard compose Row and Column layout composables was covered in the previous chapter, in most situations you will be more likely to make use of the LazyColumn and LazyRow components. Not only do these provide a more efficient way to display long lists of items, but the lazy…
-
A Jetpack Compose Row and Column List Tutorial
In this chapter, we will create a project that makes use of the Column and Row components to display items in a list format. In addition to creating the list, the tutorial will also enable scrolling and provide a demonstration of programmatic scrolling. Creating the ListDemo project Launch Android Studio and select the New Project…