why is there content_main.xml and activity_main.xml by default instead of just activity_main.xml?

后端 未结 5 1957
不思量自难忘°
不思量自难忘° 2021-01-14 00:52

I have just begun learning Android App development. I have Android Studio 1.4. In my layout folder I have two XML files (content_main.xml and activity_mai

5条回答
  •  不知归路
    2021-01-14 01:06

    The modern Android approach is based on Fragments, which are, in a way, "small Activities", which you can put in Activities, gaining lots of flexibility.

    Therefore, activity_main.xml is simply the Activity layout containing a container (FrameLayout most probably) and content_main.xml is the layout for a Fragment put into this container somewhere within MainActivity.java. You should study the code in there to understand it better :)

提交回复
热议问题