简体   繁体   English

android中的“ Layout Inflator”和“ Fragment Layout”

[英]“Layout Inflator ” and “Fragment Layout” in android

Plz解释了android中“ Layout Inflator”和“ Fragment Layout”功能之间的区别,这是这两种情况的最佳用例。

Layoutinflator and Frame layout are 2 different concept. Layoutinflator和Frame布局是2个不同的概念。 Layoutinflator is used to insansiate views to a view where as frame layout is viewgroup that can hold single item at a time. Layoutinflator用于将视图插入到一个视图中,因为框架布局是可以同时容纳单个项目的视图组。

For more details https://developer.android.com/reference/android/view/LayoutInflater.html https://developer.android.com/reference/android/widget/FrameLayout.html 有关更多详细信息, 参见https://developer.android.com/reference/android/view/LayoutInflater.html https://developer.android.com/reference/android/widget/FrameLayout.html

**Layout Inflator:**

 - Layout inflator is used to inflate UI(our desire layout xml). It is
   similar to setContentView(view)

   It can be replace setContentView.

   It will be handy in fragments, since We are not able to use
   setContentView in fragments.

   We can use inflator in both activity and fragments. e.g. If you want
   to customize dialog alert or pop up etc..

**FrameLayout**

 - FrameLayout is designed to block out an area on the screen to display
   a single item.

   FrameLayout should be used to hold a single child view, because it
   can be difficult to organize child views in a way that's scalable to
   different screen sizes without the children overlapping each other.

   FrameLayout is designed to display single item. It can be handy in
   fragments , since it holds single item.

As https://stackoverflow.com/users/6325805/writingforanroidoid has mentioned, layoutinflater and framelayout are two different concepts. 正如https://stackoverflow.com/users/6325805/writingforanroidoid所提到的,layoutinflater和framelayout是两个不同的概念。

But I guess the guys asks about fragmentlayout and not framelayout. 但是我想这家伙问的是fragmentlayout而不是framelayout。 To my knowledge, there is no entity by that name in Android. 据我所知,Android中没有该名称的实体。 However, when you use a fragment inside an activity, the fragment has to define it's layout(and the activity just could include the fragment) and may be that's what is fragment layout. 但是,当您在活动中使用片段时,该片段必须定义其布局(活动只能包含该片段),这可能就是片段布局。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM