今天在項目中遇到這個問題。上網看看了看,發現也有很多網友遇到同樣的問題。
簡單google了幾篇文章,發現瞭解決方法:
官方API有說明:
public void setLayoutParams (ViewGroup.LayoutParams params)
Set the layout parameters associated with this view. These supply parameters to the parent of this view specifying how it should be arranged. There are many subclasses of ViewGroup.LayoutParams, and these correspond to the different subclasses of ViewGroup that are responsible for arranging their children.
Parameters
params | The layout parameters for this view, cannot be null |
---|