Why do we use setLayoutParams?
问题 For example, if you want ot change LayoutParams of some view to WRAP_CONTENT for both width and height programmaticaly, it will look somethong like this : final ViewGroup.LayoutParams lp = yourView.getLayoutParams(); lp.height = ViewGroup.LayoutParams.WRAP_CONTENT; lp.width = ViewGroup.LayoutParams.WRAP_CONTENT; As i undestood getLayoutParams returns reference for params, so this code would be enough, but i often see in examples and so on that after this lines, one follows: yourView