看別人的項目時,發現竟然用這樣一種方式構建
LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE
查了下資料,才發現原來我們日常所用的
public View inflate (int resource, ViewGroup root, boolean attachToRoot)
的源碼就是調用這個方法,原來大牛都是源碼控哦!
至于這三個參數的正確使用姿勢,root如果不為空,就能獲取到layout_開頭的屬性了。