set view layout params android

Solutions on MaxInterview for set view layout params android by the best coders in the world

showing results for - "set view layout params android"
Nassim
30 Jul 2016
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