We often call the inflate method of two parameters in the adapter GetView method of the ListView,
null);
We may find that the Layout_width Layout_height property of the layout outer layer does not work, and it all becomes the value of wrap_content.
The problem is that because we use the wrong parameters, the system will ignore Layoutparams if the incoming root is empty when inflate layout.
So inside the GetView should be called
false);
This allows all the properties of layout in the R.layout.adv_viewpager layout XML file to take effect.
So what is the role of attachtoroot? He will automatically add layout to view hierarchy, do not need to call Root.addview manually, of course, in Adapter.getview do not have to manually call Root.addview because adapter has helped us do, So if we pass attachtoroot to true in Adapter.getview, we will get an error, because a view cannot be attach two times.
"Android Interface effect 43" Android Layoutinflater inflate method in Attachtoroot role