Created
January 17, 2018 10:47
-
-
Save karayok/63c537a5cb93a967caca718a65b01cad to your computer and use it in GitHub Desktop.
Get screen size (Android/Kotlin)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import android.content.Context.WINDOW_SERVICE | |
// import android.view.WindowManager | |
// import android.graphics.Point | |
// privat val size by lazy { | |
private val size = { | |
Point().also { | |
(context.getSystemService(WINDOW_SERVICE) as WindowManager) | |
.defaultDisplay | |
.apply { getSize(it) } | |
} | |
} | |
val width = size.x | |
val height = size.y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment