【问题标题】:Custom Compose Arrangement to add extra spacing at beginning and end of a LazyRow/LazyColumn自定义 Compose Arrangement 以在 LazyRow/LazyColumn 的开头和结尾添加额外的间距
【发布时间】:2022-11-24 23:38:55
【问题描述】:

如何为 LazyRow 创建自定义 Arrangement 以在开头和结尾添加额外的间距,但两者之间的间距均匀?

开始|<更多空间> Item 1 Item 2 Last Item |End

object CustomArrangement : Arrangement.Horizontal {
  override fun Density.arrange(
    totalSize: Int,
    sizes: IntArray,
    layoutDirection: LayoutDirection,
    outPositions: IntArray
  ) {

  }
}

https://developer.android.com/jetpack/compose/lists#custom-arrangements

【问题讨论】:

    标签: android android-jetpack-compose jetpack


    【解决方案1】:

    这不是您问题的答案,但您可以通过添加页眉和页脚项目来实现相同的效果。

    就像是:

    LazyColumn(
        verticalArrangement =  Arrangement.spacedBy(8.dp),
        modifier= Modifier.fillMaxSize()
    ) {
        //Header
        item(){
            Spacer(modifier = Modifier.height(40.dp))
        }
        items(itemsList) {
            Text("Item is $it")
        }
        //Footer
        item(){
            Spacer(modifier = Modifier.height(40.dp))
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2022-09-26
      • 1970-01-01
      • 1970-01-01
      • 2021-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多