Width, Smallest Width and Height

Did you know you can check the smallest width of whatever virtual device your using with this code?

Configuration config = getResources().getConfiguration();

Because i sure as heck didn’t.

Also you can get the current width and height with this:

DisplayMetrics displayMetrics = this.getResources().getDisplayMetrics();
            float dpHeight = displayMetrics.heightPixels / displayMetrics.density;
            float dpWidth = displayMetrics.widthPixels / displayMetrics.density;

Be careful though as this apparently changes depending on if the device is in portrait or landscape mode.

Filed under: AndroidTagged with: ,

No comment yet, add your voice below!

Add a Comment

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

Comment *
Name *
Email *