I know this kind of question has been asked many times but none of them helped me.
I want different integer values for my 4, 5 and 5.5 inch devices. For that I have created different values folder like values-small
, values-normal
and values-large
But every time I am getting value from values-normal
only. None of this work for me.
I have also tired to calculate minimum width using following formula. To get minimum width and create folder accordingly.
DisplayMetrics dm = this.getApplicationContext().getResources().getDisplayMetrics();
float screenWidth = dm.widthPixels / dm.density;
float screenHeight = dm.heightPixels / dm.density;
Still I am getting same result. Please help me to figure this out.
My testing devices are HTC ONE X(4.7 inch), Moto G3(5 inch) amd Meizu MX5 (5.5 inch)
I dont know why but i was getting same smallest width for my HTC (4.7) and Moto3G (5). So i switched to heard coding it.
well for now i have solved this with the help of this. I am calculating smallest width at run time and get my desired output using if..else. I dont know this is the best solution or not, but working for me at this time.
Looking for batter solution or suggestion.