Preview
-
Cmn
@MustBeDocumented
@Retention(value = AnnotationRetention.BINARY)
@Target(allowedTargets = [AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.FUNCTION])
@Repeatable
annotation Preview
Preview can be applied to either of the following:
-
@
Composablemethods with no parameters to show them in the Android Studio preview. -
Annotation classes, that could then be used to annotate @
Composablemethods or other annotation classes, which will then be considered as indirectly annotated with thatPreview.
The annotation contains a number of parameters that allow to define the way the @Composable will be rendered within the preview.
The passed parameters are only read by Studio when rendering the preview.
Summary
Public constructors |
|
|---|---|
|
Cmn
|
Public properties |
||
|---|---|---|
Int |
API level to be used when rendering the annotated @ |
Cmn
|
Long |
The 32-bit ARGB color int for the background or 0 if not set |
Cmn
|
String |
Device string indicating the device to use in the preview. |
Cmn
|
Float |
User preference for the scaling factor for fonts, relative to the base density scaling. |
Cmn
|
String |
Group name for this @ |
Cmn
|
Int |
Max height in DP the annotated @ |
Cmn
|
String |
Current user preference for the locale, corresponding to locale resource qualifier. |
Cmn
|
String |
Display name of this preview allowing to identify it in the panel. |
Cmn
|
Boolean |
If true, the @ |
Cmn
|
Boolean |
If true, the status bar and action bar of the device will be displayed. |
Cmn
|
Int |
Bit mask of the ui mode as per |
Cmn
|
Int |
Integer defining which wallpaper from those available in Android Studio to use for dynamic theming. |
Cmn
|
Int |
Max width in DP the annotated @ |
Cmn
|
Public constructors
Preview
Preview(
name: String = "",
group: String = "",
apiLevel: @IntRange(from = 1) Int = -1,
widthDp: Int = -1,
heightDp: Int = -1,
locale: String = "",
fontScale: @FloatRange(from = 0.01) Float = 1.0f,
showSystemUi: Boolean = false,
showBackground: Boolean = false,
backgroundColor: Long = 0,
uiMode: Int = 0,
device: String = Devices.DEFAULT,
wallpaper: Int = Wallpapers.NONE
)
| Parameters | |
|---|---|
name: String = "" |
Display name of this preview allowing to identify it in the panel. |
group: String = "" |
Group name for this @ |
apiLevel: @IntRange(from = 1) Int = -1 |
API level to be used when rendering the annotated @ |
widthDp: Int = -1 |
Max width in DP the annotated @ |
heightDp: Int = -1 |
Max height in DP the annotated @ |
locale: String = "" |
Current user preference for the locale, corresponding to locale resource qualifier. By default, the |
fontScale: @FloatRange(from = 0.01) Float = 1.0f |
User preference for the scaling factor for fonts, relative to the base density scaling. |
showSystemUi: Boolean = false |
If true, the status bar and action bar of the device will be displayed. The @ |
showBackground: Boolean = false |
If true, the @ |
backgroundColor: Long = 0 |
The 32-bit ARGB color int for the background or 0 if not set |
uiMode: Int = 0 |
Bit mask of the ui mode as per |
device: String = Devices.DEFAULT |
Device string indicating the device to use in the preview. See the available devices in |
wallpaper: Int = Wallpapers.NONE |
Integer defining which wallpaper from those available in Android Studio to use for dynamic theming. |
Public properties
backgroundColor
val backgroundColor: Long
The 32-bit ARGB color int for the background or 0 if not set
device
val device: String
Device string indicating the device to use in the preview. See the available devices in Devices.
fontScale
val fontScale: Float
User preference for the scaling factor for fonts, relative to the base density scaling.
group
val group: String
Group name for this @Preview. This allows grouping them in the UI and display only one or more of them.
heightDp
val heightDp: Int
Max height in DP the annotated @Composable will be rendered in. Use this to restrict the size of the rendering viewport.
locale
val locale: String
Current user preference for the locale, corresponding to locale resource qualifier. By default, the default folder will be used. To preview an RTL layout use a locale that uses right to left script, such as ar (or the ar-rXB pseudo locale).
showBackground
val showBackground: Boolean
If true, the @Composable will use a default background color.
showSystemUi
val showSystemUi: Boolean
If true, the status bar and action bar of the device will be displayed. The @Composable will be render in the context of a full activity.
wallpaper
val wallpaper: Int
Integer defining which wallpaper from those available in Android Studio to use for dynamic theming.
widthDp
val widthDp: Int
Max width in DP the annotated @Composable will be rendered in. Use this to restrict the size of the rendering viewport.