Issue
I'm going through Android Studio(in Kotlin) codelabs created by Google. One thing gets me confused when they write something like: "you need to inflate the layout and bind individual views."
When I google what inflate means, I get answers like:
- When you write an XML layout, it will be inflated by the Android OS which basically means that it will be rendered by creating view object in memory.
- Inflating is the process of adding a view (. xml) to activity on runtime.
- Layout inflater just reads the XML file and creates the specified views via reflection in top-down order
Okay, so the points above give slightly different answers. I understand from the explanations above that the .xml layout is rendered to create views. But then, why is it called inflating? Does the .xml inflate like a balloon into a view, and the balloon-like .xml is saved in memory somehow?
I can't find a good visual explanation, except code pieces on the internet. But code pieces, in this case, are not making this more sense to me.
Links to the bullet points:
- What does it mean to inflate a view from an xml file?
- https://www.reddit.com/r/androiddev/comments/mwzfj8/eli5_layout_inflation/
Solution
I guess the question is kind of subjective. But I would like to give my take on it. I believe it is indeed named after inflating balloons. A deflated balloon (xml file) sort of determines what an inflated balloon (an actual instance of a View) is supposed to look like. It is sort of like a blueprint. Inflating a balloon changes it from a unusable state to a usable one. Something similar happens here. But no one can really answer this question besides the people that created Android.
Answered By - Ivo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.