Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-07-17 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-17 UTC."],[],[],null,["# Dimension\n=========\n\nArtifact: [androidx.annotation:annotation](/jetpack/androidx/releases/annotation) \n[View Source](https://cs.android.com/search?q=file:androidx/annotation/Dimension.jvm.kt+class:androidx.annotation.Dimension) \nAdded in [1.0.0](/jetpack/androidx/releases/annotation#1.0.0)\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/androidx/annotation/Dimension \"View this page in Java\")\nCommon/AllAndroid/JVMNative/C/iOS\n - android \n\n ```\n @MustBeDocumented\n @Retention(value = AnnotationRetention.BINARY)\n @Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FIELD, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.ANNOTATION_CLASS])\n annotation Dimension\n ```\n\n*** ** * ** ***\n\nDenotes that an integer parameter, field or method return value is expected to represent a dimension.\n\nSummary\n-------\n\n| ### Constants |\n|-------------------------------------------------------------------------------------|------------------------------------------------------------------|---------|\n| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [DP](/reference/kotlin/androidx/annotation/Dimension#DP())` = 0` | android |\n| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [PX](/reference/kotlin/androidx/annotation/Dimension#PX())` = 1` | android |\n| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SP](/reference/kotlin/androidx/annotation/Dimension#SP())` = 2` | android |\n\n| ### Public constructors |\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|\n| [Dimension](/reference/kotlin/androidx/annotation/Dimension#Dimension(kotlin.Int))`(unit: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` | android |\n\n| ### Public properties |\n|-----------------------------------------------------------------------------|----------------------------------------------------------------|---------|\n| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [unit](/reference/kotlin/androidx/annotation/Dimension#unit()) | android |\n\nConstants\n---------\n\n### DP\n\nandroid \nAdded in [1.5.0](/jetpack/androidx/releases/annotation#1.5.0) \n\n```\nconst val DP = 0: Int\n``` \n\n### PX\n\nandroid \nAdded in [1.5.0](/jetpack/androidx/releases/annotation#1.5.0) \n\n```\nconst val PX = 1: Int\n``` \n\n### SP\n\nandroid \nAdded in [1.5.0](/jetpack/androidx/releases/annotation#1.5.0) \n\n```\nconst val SP = 2: Int\n```\n\nPublic constructors\n-------------------\n\n### Dimension\n\nandroid \n\n```\nDimension(unit: Int = PX)\n```\n\nPublic properties\n-----------------\n\n### unit\n\nandroid \n\n```\nval unit: Int\n```"]]