androidx.compose.ui.res
Kotlin
|Java
Top-level functions summary
AnimatedImageVector |
animatedVectorResource(@DrawableRes id: Int) Load an AnimatedImageVector from an Android resource id. |
Boolean |
booleanResource(@BoolRes id: Int) Load a boolean resource. |
Color |
colorResource(@ColorRes id: Int) Load a color resource. |
Dp |
dimensionResource(@DimenRes id: Int) Load a dimension resource. |
Typeface |
fontResource(fontFamily: FontFamily) Synchronously load an font from FontFamily. |
IntArray |
integerArrayResource(@ArrayRes id: Int) Load an array of integer resource. |
Int |
integerResource(@IntegerRes id: Int) Load an integer resource. |
Painter |
painterResource(@DrawableRes id: Int) Create a Painter from an Android resource id. |
Array<String> |
stringArrayResource(@ArrayRes id: Int) Load a string resource. |
String |
stringResource(@StringRes id: Int) Load a string resource. |
String |
stringResource(@StringRes id: Int, vararg formatArgs: Any) Load a string resource with formatting. |
Top-level functions
animatedVectorResource
@Composable fun animatedVectorResource(@DrawableRes id: Int): AnimatedImageVector
Load an AnimatedImageVector from an Android resource id.
Note: This API is transient and will be likely removed for encouraging async resource loading.
import androidx.compose.foundation.Image import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.size import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.res.animatedVectorResource @OptIn(ExperimentalComposeUiApi::class) @Composable fun AnimatedVector(@DrawableRes drawableId: Int) { val image = animatedVectorResource(drawableId) var atEnd by remember { mutableStateOf(false) } Image( painter = image.painterFor(atEnd), contentDescription = "Your content description", modifier = Modifier.size(64.dp).clickable { atEnd = !atEnd } ) }
Parameters | |
---|---|
id: Int | the resource identifier |
Return | |
---|---|
an animated vector drawable resource. |
booleanResource
@Composable fun booleanResource(@BoolRes id: Int): Boolean
Load a boolean resource.
Parameters | |
---|---|
id: Int | the resource identifier |
Return | |
---|---|
the boolean associated with the resource |
colorResource
@Composable fun colorResource(@ColorRes id: Int): Color
Load a color resource.
Parameters | |
---|---|
id: Int | the resource identifier |
Return | |
---|---|
the color associated with the resource |
dimensionResource
@Composable fun dimensionResource(@DimenRes id: Int): Dp
Load a dimension resource.
Parameters | |
---|---|
id: Int | the resource identifier |
Return | |
---|---|
the dimension value associated with the resource |
fontResource
@Composable fun fontResource(fontFamily: FontFamily): Typeface
Synchronously load an font from FontFamily.
Parameters | |
---|---|
fontFamily: FontFamily | the fontFamily |
Return | |
---|---|
the decoded image data associated with the resource |
integerArrayResource
@Composable fun integerArrayResource(@ArrayRes id: Int): IntArray
Load an array of integer resource.
Parameters | |
---|---|
id: Int | the resource identifier |
Return | |
---|---|
the integer array associated with the resource |
integerResource
@Composable fun integerResource(@IntegerRes id: Int): Int
Load an integer resource.
Parameters | |
---|---|
id: Int | the resource identifier |
Return | |
---|---|
the integer associated with the resource |