我正在开发我的第一个完全由 Compose 设计的应用程序。
我需要使用Text()
撰写组件垂直居中文本。在传统的 Android 开发实践中,我是通过对齐属性来实现这一点的。Text()
compose 也具有对齐属性,但目前它的容量有限(Alignment.Horizontal()
仅允许),尽管我Text()
在 web 中进行研究时注意到不同的对齐值。类似的情况Column()
- 它也具有对齐属性.wrapContentSize()
,并且对此处可以使用的值也有限制,尽管网络上的快速研究表明它CenterVertically
也可能会收到。
你是用什么方法来达到这种视觉效果的?完整的代码片段如下
@ExperimentalUnitApi
@Composable
fun TripBookingContent(state: PassengerTripUiState.TripBookUiState) {
Log.d(App.TAG, "[screen] TripBookingContent")
val baselineGrid = dimensionResource(id = R.dimen.baseline_grid)
val mainPadding = dimensionResource(id = R.dimen.main_margin_compact)
var componentSpace = dimensionResource(id = R.dimen.component_space)
Column(
modifier = Modifier
.wrapContentHeight()
.fillMaxWidth()
.padding(
paddingValues = PaddingValues(
horizontal = mainPadding,
vertical = baselineGrid
)
)
) {
TripViewItem(
data = state.trip,
{},
modifier = Modifier.padding(vertical …
Run Code Online (Sandbox Code Playgroud) 我正在将我的项目从 Groovy DSL 迁移到 Kotlin DSL,并且有两件事我还没有找到在 Kotlin DSL 上重写的方法。
Groovy DSL:
android {
namespace "com.example"
}
Run Code Online (Sandbox Code Playgroud)
Groovy DSL
android {
testOptions {
unitTests.returnDefaultValues = true
}
}
Run Code Online (Sandbox Code Playgroud)
在此感谢您的帮助。
我正在解决由新库引起的构建过程导致的重复问题。有一些重复的类或整个包bouncycastle
。问题是排除一个类或整个组的默认方式带来了这个问题:
Caused by: groovy.lang.GroovyRuntimeException: Cannot set the value of read-only property 'group' for DefaultExternalModuleDependency{group='org.web3j', name='core', version='4.8.7-android', configuration='default'} of type org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency
Run Code Online (Sandbox Code Playgroud)
代码本身:
implementation('org.web3j:core:4.8.7-android') {
exclude(group = 'org.bouncycastle')
}
Run Code Online (Sandbox Code Playgroud)
过去几年排除的用法有什么变化吗?