Legen Sie Layoutparameter im DP -Wert ein

float factor = getResources().getDisplayMetrics().density;
int pxWidth = (int)(dpWidth * factor);
int pxHeight = (int)(dpHeight * factor);
LinearLayout.LayoutParams layoutParams = 
  new LinearLayout.LayoutParams(pxWidth, pxHeight);
Yonathan Shterenberg