android中的“布局充气器”和“片段布局”

时间:2016-10-21 03:45:39

标签: android

Plz解释了android中“布局充气器”和“片段布局”的功能之间的区别,这两者是这两者的最佳用户案例场景。

3 个答案:

答案 0 :(得分:0)

Layoutinflator和Frame布局是两个不同的概念。 Layoutinflator用于将视图隐藏到视图中,其中框架布局是可以一次保存单个项目的视图组。

了解更多详情 https://developer.android.com/reference/android/view/LayoutInflater.html https://developer.android.com/reference/android/widget/FrameLayout.html

答案 1 :(得分:0)

**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.

答案 2 :(得分:0)

正如https://stackoverflow.com/users/6325805/writingforanroidoid所提到的,layoutinflater和framelayout是两个不同的概念。

但我猜这些人会询问有关fragmentlayout而不是framelayout。据我所知,Android中没有该名称的实体。但是,当您在活动中使用片段时,片段必须定义它的布局(并且活动可能包含片段),这可能就是片段布局。