DEV Community

Kai's brain dump
Kai's brain dump

Posted on • Edited on • Originally published at braindumpk.substack.com

2 2

Get Android's screen width and height

Inside your Activity:

override fun onStart() {
    val size = Point()
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
        requireContext().display!!.getRealSize(size)
    } else {
        val windowManager = requireContext().getSystemService(Context.WINDOW_SERVICE) as WindowManager
        windowManager.defaultDisplay.getRealSize(size)
    }
    size.x // Width
    size.y // Height
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more