"Android Interface effect 43" Android Layoutinflater inflate method in Attachtoroot role

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.