gpt4 book ai didi

android - 选择显示预览的设备,jetpack compose

转载 作者:行者123 更新时间:2023-12-04 23:43:44 29 4
gpt4 key购买 nike

在 View 系统中,我们可以为不同的设备选择 XML 预览,但我找不到为 Jetpack Compose 选择预览设备的方法。
我们如何在使用 Jetpack Compose 时为不同的设备设置预览?

最佳答案

你可以这样做

@Preview(device = Devices.PIXEL_2_XL)
@Composable
fun DefaultPreview() {
MyApplicationFooTheme {
Greeting("Android")
}
}
可用设备列表在这里
object Devices {
const val DEFAULT = ""

const val NEXUS_7 = "id:Nexus 7"
const val NEXUS_7_2013 = "id:Nexus 7 2013"
const val NEXUS_5 = "id:Nexus 5"
const val NEXUS_6 = "id:Nexus 6"
const val NEXUS_9 = "id:Nexus 9"
const val NEXUS_10 = "name:Nexus 10"
const val NEXUS_5X = "id:Nexus 5X"
const val NEXUS_6P = "id:Nexus 6P"
const val PIXEL_C = "id:pixel_c"
const val PIXEL = "id:pixel"
const val PIXEL_XL = "id:pixel_xl"
const val PIXEL_2 = "id:pixel_2"
const val PIXEL_2_XL = "id:pixel_2_xl"
const val PIXEL_3 = "id:pixel_3"
const val PIXEL_3_XL = "id:pixel_3_xl"
const val PIXEL_3A = "id:pixel_3a"
const val PIXEL_3A_XL = "id:pixel_3a_xl"
const val PIXEL_4 = "id:pixel_4"
const val PIXEL_4_XL = "id:pixel_4_xl"

const val AUTOMOTIVE_1024p = "id:automotive_1024p_landscape"
}

关于android - 选择显示预览的设备,jetpack compose,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67724202/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com