相关疑难解决方法(0)

如何控制 Jetpack Compose 中的 DropDownMenu 位置

我有一行在开头对齐文本,在结尾对齐图像。当我按下图像时,我会显示一个下拉菜单,但它出现在行的开头,我希望它出现在行的末尾。

我尝试在 Modifier 组件中使用 Alignment.centerEnd 但不起作用。

我怎样才能让弹出窗口出现在行的末尾?

@Composable
fun DropdownDemo(currentItem: CartListItems) {
    var expanded by remember { mutableStateOf(false) }
    Box(modifier = Modifier
        .fillMaxWidth()) {
        Text(modifier = Modifier.align(Alignment.TopStart),
            text = currentItem.type,
            color = colorResource(id = R.color.app_grey_dark),
            fontSize = 12.sp)
        Image(painter = painterResource(R.drawable.three_dots),
            contentDescription = "more options button",
            Modifier
                .padding(top = 5.dp, bottom = 5.dp, start = 5.dp)
                .align(Alignment.CenterEnd)
                .width(24.dp)
                .height(6.75.dp)
                .clickable(indication = null,
                    interactionSource = remember { MutableInteractionSource() },
                    onClick = {
                        expanded = true
                    }))
        DropdownMenu(
            expanded = expanded,
            onDismissRequest …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-jetpack-compose composable

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