为什么用于片段的FrameLayout? [英] Why is a FrameLayout used for fragments?
问题描述
无论我在哪看, FrameLayout
似乎都被用作 FragmentContainer
。
为什么 FrameLayout
总是出现在碎片
?
LinearLayout
它仍然可以工作,但你的问题的答案在 FrameLayout
的文档中:
FrameLayout旨在阻挡屏幕上的区域以显示
a单个项目。一般来说,FrameLayout应该用来保存一个
的子视图,因为以
的方式组织子视图是很困难的,这种方式可以扩展到不同的屏幕尺寸,而不需要孩子
相互重叠。但是,您可以将多个子元素添加到
FrameLayout中,并使用android:layout_gravity
属性为每个子元素赋予重力
来控制其在FrameLayout中的位置。
您可以在这里阅读更多有关 FrameLayout
的信息: FrameLayout / Android开发人员
Wherever I look, FrameLayout
seems to be used as the FragmentContainer
.
Why is FrameLayout
always seen with Fragments
?
You can basically use RelativeLayout
or LinearLayout
it will still work,but the answer of your question is in FrameLayout
's documentation :
FrameLayout is designed to block out an area on the screen to display a single item. Generally, 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. You can, however, add multiple children to a FrameLayout and control their position within the FrameLayout by assigning gravity to each child, using the android:layout_gravity attribute.
You can read more about FrameLayout
here : FrameLayout/Android Developers
这篇关于为什么用于片段的FrameLayout?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!