A way of getting screen sizes of the device in pixels and density independent pixels (dp)

Get screen width in pixels:

Java:

Kotlin:

Get screen height in pixels:

Java:

Kotlin:

Get screen width in dp (density pixels):

Java:

Kotlin:

Get screen height in dp (density pixels):

Java:

Kotlin:

Get screen density:

Java:

Kotlin:

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *