What can be the difference of using a fragment and frameLayout in android? Can both be used interchangeably?

后端 未结 2 1395
误落风尘
误落风尘 2021-02-13 12:46

I have seen an approach where frameLayout is used in case of fragments. The ultimate goal was to have multiple fragments.

2条回答
  •  别那么骄傲
    2021-02-13 13:04

    A framelayout, Relative View and a few others represents a view in android and is extended from viewgroup.

    A Fragment is a an an Object that is used to represent a portion of a user interface and is usually hosted in an activity.

    A fragment has a viewgroup which you can assign an XML layout. In the XML you can specify a viewgroup which can be a framelayout if you wish to represent the layout of the viewgroup within the fragment.

    Fragments and framelayouts cannot be used interchangeably.

    Having said that, you can create a Android application without the use of fragments, and just use viewgroups.

提交回复
热议问题