Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able Collabs tool bar manully #71

Open
aniluMango opened this issue Jan 19, 2023 · 0 comments
Open

Not able Collabs tool bar manully #71

aniluMango opened this issue Jan 19, 2023 · 0 comments

Comments

@aniluMango
Copy link

I want to scroll my list and collapse my toolbar to show scroll items but when i call collapse() it not working. following is the my compose method.

@Composable
fun Collapsing() {
    val scope = rememberCoroutineScope()
    val rememberLazyListState = rememberLazyListState()
    val scaffoldState = rememberCollapsingToolbarScaffoldState()
    CollapsingToolbarScaffold(
        state = scaffoldState,
        scrollStrategy = ScrollStrategy.EnterAlwaysCollapsed,// provide the state of the scaffold
        toolbar = {
            Text(text = "My Activity", modifier = Modifier
                .fillMaxWidth()
                .height(200.dp)
                .background(color = Color.Red)
                .clickable {
                    scope.launch {
                        scaffoldState.toolbarState.scroll {
                            scrollBy(-scaffoldState.toolbarState.height.toFloat())
                        }
                        rememberLazyListState.scrollToItem(50)
                    }
                })
        },
        body = {
             LazyColumn(modifier = Modifier.fillMaxSize(), state = rememberLazyListState) {
                items(100) {
                    Row(
                        modifier = Modifier
                            .fillMaxWidth()
                            .clickable {
                                scope.launch {
                                    rememberLazyListState.scrollToItem(50)
                                }

                            },
                    ) {
                        Text(modifier = Modifier.padding(16.dp), text = it.toString())
                    }
                }
            }
        },
        modifier = Modifier,
    )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant