运行 Studio 中模拟器上的 运行 应用程序如何充当此角色?
How a running application on an emulator in Android Studio can act as this?
在 Android Studio(Bumblebee 2021.1.1 补丁 2)中尝试 Jetpack Compose 的一些代码,我惊讶地看到模拟器上的应用程序 运行 在我修改值时充当交互在代码 window 中。
我说的正是模拟器 (Pixel_3a_API_30x86) 运行 应用程序,而不是预览(设计)window。
这怎么可能 ?没有新的编译,没有新的安装?
如果有人能解释一下,非常感谢。
@Preview
@Composable
fun MyBox(
modifier: Modifier = Modifier,
contentAlignModifier: Modifier = Modifier
) {
Box(modifier = Modifier.fillMaxSize()) {
Text(
text = stringResource(id = R.string.first),
fontSize = 20.sp,
modifier = contentAlignModifier.align(Alignment.TopStart)
)
Text(
text = stringResource(id = R.string.second),
fontSize = 24.sp,
modifier = contentAlignModifier.align(Alignment.Center)
)
Text(
text = stringResource(id = R.string.third),
fontSize = 28.sp,
modifier = contentAlignModifier.align(Alignment.BottomEnd)
)
}
*// when the application is running on the emulator in Android Studio
// if I modifiy below the value of Modifier.size
// I can see immediatly the result on the screen of the emulator
// How is it possible whithout a new compilation and a new installation ?*
// **(I'm speaking of the running emulator, not of the preview window...)**
Box(modifier = Modifier.size(500.dp),
contentAlignment = Alignment.BottomCenter) {
Text(
text = "Voici mon texte !"
)
}
}
Jetpack Compose 具有 Hot Reload
功能。与 Xamarin 中看到的类似。
在 Android Studio(Bumblebee 2021.1.1 补丁 2)中尝试 Jetpack Compose 的一些代码,我惊讶地看到模拟器上的应用程序 运行 在我修改值时充当交互在代码 window 中。 我说的正是模拟器 (Pixel_3a_API_30x86) 运行 应用程序,而不是预览(设计)window。 这怎么可能 ?没有新的编译,没有新的安装? 如果有人能解释一下,非常感谢。
@Preview
@Composable
fun MyBox(
modifier: Modifier = Modifier,
contentAlignModifier: Modifier = Modifier
) {
Box(modifier = Modifier.fillMaxSize()) {
Text(
text = stringResource(id = R.string.first),
fontSize = 20.sp,
modifier = contentAlignModifier.align(Alignment.TopStart)
)
Text(
text = stringResource(id = R.string.second),
fontSize = 24.sp,
modifier = contentAlignModifier.align(Alignment.Center)
)
Text(
text = stringResource(id = R.string.third),
fontSize = 28.sp,
modifier = contentAlignModifier.align(Alignment.BottomEnd)
)
}
*// when the application is running on the emulator in Android Studio
// if I modifiy below the value of Modifier.size
// I can see immediatly the result on the screen of the emulator
// How is it possible whithout a new compilation and a new installation ?*
// **(I'm speaking of the running emulator, not of the preview window...)**
Box(modifier = Modifier.size(500.dp),
contentAlignment = Alignment.BottomCenter) {
Text(
text = "Voici mon texte !"
)
}
}
Jetpack Compose 具有 Hot Reload
功能。与 Xamarin 中看到的类似。