What does it mean to inflate a view from an xml file?

前端 未结 6 1756
情书的邮戳
情书的邮戳 2020-11-28 17:35

I am new to android development and keep coming across references to Inflating views from a layout xml file. I googled and searched the development guide but still wasn\'t

6条回答
  •  难免孤独
    2020-11-28 17:51

    "Inflating" a view means taking the layout XML and parsing it to create the view and viewgroup objects from the elements and their attributes specified within, and then adding the hierarchy of those views and viewgroups to the parent ViewGroup. When you call setContentView(), it attaches the views it creates from reading the XML to the activity. You can also use LayoutInflater to add views to another ViewGroup, which can be a useful tool in a lot of circumstances.

提交回复
热议问题