Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

set layout params in dp value

float factor = getResources().getDisplayMetrics().density;
int pxWidth = (int)(dpWidth * factor);
int pxHeight = (int)(dpHeight * factor);
LinearLayout.LayoutParams layoutParams = 
  new LinearLayout.LayoutParams(pxWidth, pxHeight);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #set #layout #params #dp
ADD COMMENT
Topic
Name
5+2 =