public T margin ( float leftDip , float topDip , float rightDip , float bottomDip ) { if ( view != null ) { ViewGroup . LayoutParams lp = view . getLayoutParams ( ) ; if ( lp instanceof ViewGroup . MarginLayoutParams ) { int left = dip2pixel ( leftDip ) ; int top = dip2pixel ( topDip ) ; int right = dip2pixel ( rightDip ) ; int bottom = dip2pixel ( bottomDip ) ; ( ( ViewGroup . MarginLayoutParams ) lp ) . setMargins ( left , top , right , bottom ) ; view . setLayoutParams ( lp ) ; } } return self ( ) ; }
Set the margin of a view . Notes all parameters are in DIP not in pixel .