android 如何在Jetpack Compose中的列背景图像上添加按钮?

23c0lvtd  于 2023-02-20  发布在  Android
关注(0)|答案(1)|浏览(202)

我想添加一个按钮的形象,这是在最后一列。这里是代码为我的专栏。

Column(
            modifier
                .fillMaxSize()
                .background(color = Background),
            horizontalAlignment = Alignment.CenterHorizontally,
        ) {
            Image(
                painter = painterResource(id = R.drawable.e_logo),
                contentDescription = "Emporium Logo",
                modifier = modifier
                    .size(150.dp, 150.dp)
                    .padding(top = 39.dp)
            )
            Text(
                text = " ",
                color = Color.White,
                fontSize = 50.sp,
                textAlign = TextAlign.Center,
                fontFamily = Oswald,
                fontWeight = FontWeight.Bold
            )
            Divider(color = Color.White, thickness = 1.dp,
                modifier = modifier
                    .padding(
                        top = 10.dp,
                        bottom = 20.dp
                    )
                    .width(140.dp))

            Text(
                text = " ",
                color = Color.White,
                fontSize = 20.sp,
                textAlign = TextAlign.Center,
                fontFamily = Poppins,
                fontWeight = FontWeight.Normal,
            )

            Image(
                painter = painterResource(id  = R.drawable.dotted_design),
                contentDescription = "Dotted Design",
                contentScale = ContentScale.FillWidth,
                modifier = modifier
                    .fillMaxWidth()
                    .height(1000.dp)

            )
        }

每当我试图把按钮上方或下方的背景图像,它是越来越取代。

ovfsdjhp

ovfsdjhp1#

使用Box将元素放在另一个元素的顶部。
比如:

Box(
      contentAlignment = Alignment.Center
  ){
      Image(
         //...
      )
      Button(
          onClick = {},
          modifier = Modifier.align(Alignment.BottomCenter).padding(bottom = xx.dp)
      ){
          Text("Connect Wallet")
      }
  }

相关问题