How can I get the screen width dpi?
DisplayMetrics metrics = getResources().getDisplayMetrics();
int f = metrics.densityDpi;
// getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width = metrics.widthPixels;
int dp = (int)(width / (metrics.density));
I do this, so lets assume my densitydpi is 120..and widthpixel 240.. via calculation i get 240/0.75.... so I have 320 widthdpi?
However that's not the case....widthdpi is smaller then 320 I think...because 320 goes with me wrong in the screen.... using 120 works.
on Nexus 4...with width 768 and densitydpi 320...I divide 768/2 and i get 384 correct width density dpi (it works)
But on other ones like 240, 160, 120 density dpi..the calculation of width dpi seems wrong ...