The following will update the layout width, height, and weight of a layout placed in an XML file for an activity.
float layoutWeight = 1;
LinearLayout layoutStuff = (LinearLayout) findViewById(R.id.main_myLinearLayout);
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, layoutWeight);
layoutStuff.setLayoutParams(layoutParams);