I have seen an approach where frameLayout is used in case of fragments. The ultimate goal was to have multiple fragments.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
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.
For showing a single Fragment immediately on the screen, yes, you can use fragment or FrameLayout interchangeably.
Single Fragment, Method 1
Showing the Fragment via the fragment tag would look like this in XML:
Single Fragment, Method 2
Showing the Fragment via FrameLayout would look like this in XML:
Followed by Java code like this:
Multiple Fragments
Method 2 then supports changing what fragment you are showing later by running more Java code to change what Fragment is there afterwards:
So FrameLayout gives you the extra ability to do that over using the fragment tag.