What are widthDp
and heightDp
as a @Preview
parameter?
【My environment】
- Android Studio Arctic Fox | 2020.3.1 Patch3 build on October 1, 2021
- Gradle: 7.0.2
- AGP: 7.0.3
- androidx.compose.ui:ui-tooling-preview:1.0.1
Here is my code.
@Preview(
showBackground = true,
widthDp = 200,
heightDp = 200,
)
@Composable
fun DefaultPreview() {
Box(modifier = Modifier.size(100.dp).background(Color.Red))
}
It seems that the box size is larger than I expected. Does anyone explain that?