Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to know if tablet or phone in Android

I have a var in Swift like this :

@Published  var textFieldSize = UIDevice.current.userInterfaceIdiom == .pad ? 20.0 :  12.0

How can i get the same device type (phone or tablet) but in Jetpack Compose Android ??

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can do this:

val configuration = LocalConfiguration.current
val expanded = configuration.screenWidthDp > 840

This corresponds to 97.22% of tablets in landscape. For sizes corresponding to phones or tablets there is more info here.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading