For some odd reason, I could n't get the proper output from the below function, I know I did some silly mistake but not sure though,
public static int convertDpToPixel(int dp, Context context){
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,dp,context.getResources().getDisplayMetrics());
return Math.round(px);
}
and i am calling the function as - gen_function.convertDpToPixel(R.dimen.button_left_right_margin,this);
The output is a huge number which is not expected, any help much appreciated.