我有一个lazyColumn,我想在列中使用它,但出现以下错误并且应用程序崩溃:
不允许在相同方向的布局中嵌套可滚动的布局,例如 LazyColumn 和 Column(Modifier.verticalScroll())。如果您想在项目列表之前添加标题,请查看 LazyColumn 组件,该组件具有 DSL api,允许首先通过 item() 函数添加标题,然后通过 items() 添加项目列表
lazyColumn 代码,我在此代码中有一个列表:
@Composable
fun UpScreenSection(
modifier: Modifier,
state: ProfileState,
viewModel: ProfileViewModel
) {
Spacer(modifier = Modifier.size(24.dp))
Column(
modifier = modifier
.fillMaxSize()
.padding(24.dp)
) {
if (!state.items.isNullOrEmpty()) {
Box(
modifier = modifier
.fillMaxSize()
) {
LazyColumn(modifier = modifier.fillMaxSize()) {
items(state.items) { item ->
ProfileListItems(item = item, onItemClick = {
//TODO Navigate to specific screen
when (it.id) {
1 -> {
}
2 -> {
}
3 -> { …
Run Code Online (Sandbox Code Playgroud) 我想删除所选项目后面的蓝色椭圆形颜色。我怎样才能做到这一点?
NavigationBarItem(
selected = selected,
onClick = onClick,
icon = if (selected) selectedIcon else icon,
modifier = modifier,
enabled = enabled,
label = label,
alwaysShowLabel = alwaysShowLabel,
colors = NavigationBarItemDefaults.colors(
selectedIconColor = AppDefaults.navigationSelectedItemColor(),
unselectedIconColor = AppDefaults.navigationContentColor(),
selectedTextColor = AppDefaults.navigationSelectedItemColor(),
unselectedTextColor = AppDefaults.navigationContentColor(),
indicatorColor = AppDefaults.navigationIndicatorColor()
)
)
Run Code Online (Sandbox Code Playgroud)
android android-jetpack-compose android-jetpack-compose-material3 material3
我当前的 Gradle 插件版本是 4.1.2,这个版本工作正常,但是当我更新到 4.1.3 时,我收到此错误,并且无法构建项目: 注意:我添加了 maven() 和 jcenter()。
A problem occurred configuring root project 'AndroidCryptography'.
Run Code Online (Sandbox Code Playgroud)
无法解析配置“:classpath”的所有工件。找不到 gradle-4.1.3.jar (com.android.tools.build:gradle:4.1.3)。在以下位置搜索: https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.3/gradle-4.1.3.jar
我的构建.gradle:
我想在 jetpack compose 中实现拖放列表项,但我想自定义一些属性。
1:不应拖动空文本项。
2:当我们绘制满的item时,如果要移动的item是空的,则必须返回。
我怎样才能创建这个?
每个人都可以写这段代码吗?
我想isMyLocationButtonEnabled
在 Google 地图上显示当前位置按钮 ( ),但它没有显示。
如何显示获取当前位置按钮?
AndroidView(
factory = { mapView }
) {
mapView.getMapAsync { map ->
map.apply {
navigatorViewModel.apply {
viewModelScope.launch {
isMapEditable.collectLatest {
uiSettings.setAllGesturesEnabled(
it,
)
uiSettings.isMyLocationButtonEnabled = true
}
}
val location = lastSelectedLocation.value
val position = LatLng(location.latitude, location.longitude)
moveCamera(
CameraUpdateFactory.newLatLngZoom(
position,
Constants.ZOOM_CAMERA
)
)
setOnCameraIdleListener {
val cameraPosition = map.cameraPosition
updateLocation(
cameraPosition.target.latitude,
cameraPosition.target.longitude
)
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 我想将“Account”文本设置到TopAppBar的中心,并在TopAppBar的右侧添加一个图标,我该怎么做?
Scaffold(
scaffoldState = scaffoldState,
topBar = {
TopAppBar(
title = {
Text(
text = stringResource(R.string.account),
style = AppFont.PoppinsTypography.subtitle1
)
},
navigationIcon = {
Icon(
painter = painterResource(id = R.drawable.ic_left),
contentDescription = "back", tint = AppColor.brandColor.BLUE_DE_FRANCE
)
}, actions = {
viewModel.navigateUp()
}, backgroundColor = AppColor.neutralColor.DOCTOR
)
},
)
Run Code Online (Sandbox Code Playgroud) android ×7
android-jetpack-compose-material3 ×1
google-maps ×1
gradle ×1
kotlin ×1
material3 ×1
plugins ×1
textfield ×1