The LayoutParams is a helper class that stores various layout information related to the Android view for which it is used.
ViewGroup is a subclass of the Android View class(parent of all Android graphical widgets) which can contain child views.
Unless you know exactly what you are doing do not use the same layoutparams for more than one viewgroup
Programmatic Margin for LinearLayout is ignored
The takeaway from this is that layoutparams are not parsed by the view s constructor they re parsed by another step that your code above isn t doing;the layoutinflater involves the parent viewgroup s generatelayoutparams method.
Error applying image style dynamically, why?