Custom focus on item of lazyrow androidtv jetpack compose

PressRex profile image
by PressRex
Custom focus on item of lazyrow androidtv jetpack compose

so i have a jetpack compose tv project and on the home screen i have a tvlazycolumn and inside it i have item{} having multiple of these :

if (resultItem.thumbnailType?.name.equals(
                                "landscape",
                                ignoreCase = true
                            ) && !resultItem.assets.isNullOrEmpty()
                        ) {        //landscape
                            TextStyle(
                                text = resultItem.categoryName ?: "",
                                modifier = Modifier.padding(top = dimensionResource(R.dimen.sixteen_dp)),
                                color = colorResource(R.color.white)
                            )
                            TvLazyRow(
                                pivotOffsets = PivotOffsets(0.0F),
                                modifier = Modifier
                                    .padding(top = dimensionResource(R.dimen.eight_dp))
                                    .onFocusChanged { focusState ->
                                    }
                            ) {
                                items(resultItem.assets?.take(10) ?: emptyList()) { asset ->
                                    LandScapeCardWithWidth(
                                        image = asset.imageLandscape!!,
                                        title = asset.name,
                                        isViewAll = false,
                                        type = asset.type,
                                        itemClick = {
                                        },
                                        modifier = Modifier,
                                        hideTag = asset.hideTag.toString(),
                                        contentAvailability = asset.contentAvailability,
                                        size = dimensionResource(R.dimen.two_hundred_dp),
                                        onFocusChange = { isFocused ->
                                            if (isFocused) {
                                                assetSynopsys = asset.synopsis
                                                languageSize = asset.languages?.size.toString()
                                                assetImage = asset.imageTransparent
                                                focusedImageUrl = asset.imageLandscape
                                                assetRating = asset.viewerRating?.ratingName
                                                assetHour = asset.hours
                                                assetMin = asset.min
                                            }
                                        }
                                    )

                                }
                            }
                        }

now what want to do is go to a specific item in the row let say on the row above this row i was on 5th item then when i press down i come to the item which was below it which is default how focus works. but i want to the focus to go on the first item of the row .

Source: View source

PressRex profile image
by PressRex

Subscribe to New Posts

Lorem ultrices malesuada sapien amet pulvinar quis. Feugiat etiam ullamcorper pharetra vitae nibh enim vel.

Success! Now Check Your Email

To complete Subscribe, click the confirmation link in your inbox. If it doesn’t arrive within 3 minutes, check your spam folder.

Ok, Thanks

Read More