You could do this
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
llParams.setMargins(0, 20, 0, 0);
ll.addView(mRecordButton, llParams);
Or you could try calling setPadding(0, 20, 0, 0) on mRecordButton before passing it into addView.