I need to convert density independent pixels to pixels in my activity. I tried using this method in my onCreate
float pix = dipValue * getResources().getDisplayMetrics().density;
pixel = Math.round(pix);
I tried another method
Resources r = getResources();
float pix = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 35,r.getDisplayMetrics());
value = Math.round(pix);
both are yielding the same value. I think the problem is not with the method but with the resources. Should I make any changes in the Manifest file like
<supports-screens android:resizeable=["true"| "false"]
android:smallScreens=["true" | "false"]
android:normalScreens=["true" | "false"]
android:largeScreens=["true" | "false"]
android:xlargeScreens=["true" | "false"]
android:anyDensity=["true" | "false"]
android:requiresSmallestWidthDp="integer"
android:compatibleWidthLimitDp="integer"
android:largestWidthLimitDp="integer"/>
There is a similar question to mine. But it is not solving my problem. Help me out.