[android] Avoid passing null as the view root (needed to resolve layout parameters on the inflated layout’s root element)

custom view에서 inflate를 할 때 이런 오류가 난다.

 

Avoid passing null as the view root (needed to resolve layout parameters on the inflated layout's root element)

 

LayoutInflater inflate = LayoutInflater.from($context);
View view = inflate.inflate(R.layout.view_left_balloon, null);

 

LayoutInflater inflate = LayoutInflater.from($context);
View view = inflate.inflate(R.layout.view_left_balloon, new LinearLayout($context), false);

or

LayoutInflater inflate = LayoutInflater.from($context);
int layoutId = R.layout.view_left_balloon;
View view = inflate.inflate(layoutId, null);