小编pra*_*rat的帖子

使用jetpack compose的突出顶部应用程序栏

我想使用 jetpack compose 在顶部应用程序栏上创建和添加类似于下面的屏幕截图的手势:

在此输入图像描述

我可以使用下面的 android 文档链接创建可折叠的顶栏: 文档链接,但无法使用 compose 进行扩展和折叠以及布局更改的手势。下面是我尝试过的可折叠工具栏的代码。

val toolbarHeight = 48.dp
val toolbarHeightPx = with(LocalDensity.current) { toolbarHeight.roundToPx().toFloat() }
// our offset to collapse toolbar
val toolbarOffsetHeightPx =

    remember { mutableStateOf(0f) }
// now, let's create connection to the nested scroll system and listen to the scroll
// happening inside child LazyColumn
val nestedScrollConnection = remember {
    object : NestedScrollConnection {
        override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
            // try to consume before LazyColumn to collapse …
Run Code Online (Sandbox Code Playgroud)

android android-jetpack-compose

7
推荐指数
1
解决办法
5456
查看次数

Jetpack Compose:检查文本最大行数

我有一个场景,如果文本最大行数超过 9,我需要显示一个按钮,否则该按钮不应出现。

我尝试查看 Android 开发人员指南,但找不到任何解决方案。

下面是我的代码:

                    Text(
                        //text = item.content,
                        text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. " +
                                "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, " +
                                "when an unknown printer took a galley of type and scrambled it to make a type specimen book. " +
                                "It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was …
Run Code Online (Sandbox Code Playgroud)

android android-jetpack-compose

2
推荐指数
1
解决办法
2338
查看次数

标签 统计

android ×2

android-jetpack-compose ×2