Compose for Wear OS: ScalingLazyColumn
source link: https://proandroiddev.com/compose-for-wear-os-scalinglazycolumn-63f754e91edb
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Compose for Wear OS: ScalingLazyColumn
In this blog post, we will explore the ScalingLazyColumn
composable. It makes adding scaling and alpha animations in a scrollable container really easy.
If you are interested in exploring other components in Compose for Wear OS you can check out other blogs that I have written.
Series pitstops
If you have used LazyColumn
in Jetpack Compose, you will find this composable similar to it. In fact, internally ScalingLazyColumn
uses LazyColumn
. Let’s understand the differences between these two composables and when to use which one while making apps in Wear OS.
Let’s add the required dependencies
Let’s have a look at the method signature of ScalingLazyColumn
If you have used LazyColumn
before, most of these parameters would look familiar to you. reverseLayout
will lay the items of the list from bottom to top and reverse the direction of scrolling if given the true value. verticalArrangement
lays the items of the list with a top or bottom alignment based on the reverseLayout
value and gives a default spacing to all the items of the list. horizontalAlignment
as the name suggests lays the the items of the list horizontally. Similar to other composables you can provide modifier
, contentPadding
, state
and content
to it.
scalingParams
is the parameter responsible for adding the scaling and alpha animations for the list items that are at the top or bottom edge of the screen. The gif later in the blog will help you to visualise this animation. The method ScalingLazyColumnDefaults.scalingParams()
takes a bunch of parameters that have default values. This is how the method signature of the above method looks like
I won’t go into detail about what each of these parameters is, I would suggest to just play around with these values to get the desired scaling and alpha animations for your list. All these float
values are between 0f
and 1f
which represents the percentage of the normal values so if edgeScale
has a value of 0.5f, its size will be 50% of its normal size when animated along the edge.
Let’s have a look at this video to see the difference between LazyColumn
and ScalingLazyColumn
On the right, you will notice that the ScalingLazyColumn
adds a subtle animation on the edges when you scroll the content inside it. While making an app in Wear OS if you want to have such animations then you should use the ScalingLazyColumn
otherwise you can use LazyColumn
and avoid the cost of calculating the scaling and alpha animations required for the list items.
This is the code required to implement ScalingLazyColumn
like the one shown in the video
The composable used inside ScalingLazyColumn
is Chip
, it is another composable that is part of the Compose for Wear OS library. You can use it to add a material design chip in your wearable apps.
If you have feedback, feel free to tweet/message me on Twitter.
Recommend
-
7
Compose for Wear OS: ScaffoldGoogle recently announced that Compose for Wear OS is in Developer Preview. In this blog post, you will understand how to use Scaffold in Wear OS to build apps using different Mate...
-
4
Compose for Wear OS: NavigationIn this blog post, we will learn how to implement navigation in Wear OS.If you are interested in exploring other components in Compose for Wear OS you can check out other blogs that I...
-
10
Compose + Wear OS: Chromatic TunerPractical example of the power of Jetpack Composebackground created by freepik — br.freepik.comIn this article I will cover the development of a chromatic tuner for Wea...
-
5
Announcing Compose for Wear OS Beta! 11 May 2022
-
2
Compose for Wear OS is now 1.0: time to build weara...
-
2
Published onWednesday, July 27, 2022Jetpack Compose 1.2.0 & Jetpack Compose Wear 1.0.0 are out – Downloadable fonts, Lazy Grids and moreAu...
-
4
Todoist adopted Compose for Wear OS...
-
3
Compose for Wear OS 1.1 is now stable: check out new features!...
-
0
-
3
Home ... ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK