1yourView.setLayoutParams(new LinearLayout.LayoutParams(
2 LinearLayout.LayoutParams.MATCH_PARENT,
3 LinearLayout.LayoutParams.WRAP_CONTENT
4 //change the parameters as whatever you want
5 ));
6//keep in mind that LinearLayout is not the only Layout, e.g. you can use ConstrainLayout etc...
7//after, you need to add yourView to a layout as it won't redraw itself if you just change the layout parameters e.g.:
8yourLayout.addView(yourView); //yourView will pop on yourLayout