简体   繁体   English

Jetpack compose 中的折叠工具栏

[英]Collapsing toolbar in Jetpack compose

How to build an Instagram profile page using Jetpack compose.如何使用 Jetpack compose 构建 Instagram 个人资料页面。 I've tried multiple libraries like NestedScrollView , CollapsingToolbar to get collapsable/scrollable Topbar but they are not looking smooth.我尝试了多个库,例如NestedScrollViewCollapsingToolbar来获得可折叠/可滚动的 Topbar,但它们看起来并不流畅。 It's easy to build with XML using CoordinatorLayout.使用 CoordinatorLayout 轻松构建 XML。

Expected Scroll:- Instagram Profile Page预期滚动:- Instagram 个人资料页面

Using NestedScrollView Library:- NestedScrollView使用 NestedScrollView 库:- NestedScrollView

This layout is easy to implement with LazyColumn and stickyHeader :这种布局很容易用LazyColumnstickyHeader实现:

LazyColumn(Modifier.fillMaxWidth()) {
    item {
        Text("Header")
    }
    stickyHeader {
        TabRow(selectedTabIndex = 0) {
            repeat(4) {
                Tab(selected = it == 0, onClick = {}) {
                    Text(
                        it.toString()
                    )
                }
            }
        }
    }
    items(100) {
        Text(it.toString())
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM