Issue
I have 4 different devices:
- Asus tablet, screensize 7"
- Lenovo tablet, screensize 7"
- HTC mobile phone, screensize 5"
- HTC mobile phone, screensize 4.7"
I want to know the smallest width (sw) of my device to make a support layout for it.
I want to make a resource folder like "layout-sw600dp" but I don't know the value of the smallest width (sw).
I tried to print the sw using this code:
DisplayMetrics metrics = getResources().getDisplayMetrics();
Log.i("Density", ""+metrics.densityDpi);
but i don't know if this is the correct value.
How do I find the smallest width (sw)?
Solution
you can try this:
DisplayMetrics dm = mActivity.getApplicationContext()
.getResources().getDisplayMetrics();
float screenWidth = dm.widthPixels / dm.xdpi;
float screenHeight = dm.heightPixels / dm.ydpi;
For Details :here
Answered By - Rustam
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.