一:
LayoutParams必須是該View的父容器,即ViewGroup的LayoutParams
原因:設置View的params,是向上級報告,自己需要多大空間,由父級分配,詳情看ViewGroup測量流程
示例:
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) WorkSginInLeftPoints.getLayoutParams();
二:
要動態設置View寬、高等必須不能是以px為單位
若,以px為單位,不會變化
其他單位,需注意單位間的換算
希望能對各位起到幫助!