为什么 FrameLayout 用于片段? [英] Why is a FrameLayout used for fragments?
问题描述
无论我在哪里,FrameLayout
似乎都被用作 FragmentContainer
.为什么 FrameLayout
总是和 Fragments
一起出现?
Wherever I look, FrameLayout
seems to be used as the FragmentContainer
.
Why is FrameLayout
always seen with Fragments
?
推荐答案
你基本上可以使用 RelativeLayout
或 LinearLayout
它仍然可以工作,但你的问题的答案是在 FrameLayout
的文档中:
You can basically use RelativeLayout
or LinearLayout
it will still work,but the answer of your question is in FrameLayout
's documentation :
FrameLayout 被设计成在屏幕上遮挡一块区域来显示单个项目.一般来说,FrameLayout 应该用于容纳单个子视图,因为很难在一个子视图中组织子视图在没有孩子的情况下可扩展到不同屏幕尺寸的方式相互重叠.但是,您可以将多个子项添加到一个FrameLayout 并通过以下方式控制它们在 FrameLayout 中的位置使用 android:layout_gravity 为每个孩子分配重力属性.
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.
您可以在此处阅读有关 FrameLayout
的更多信息:FrameLayout/Android 开发人员一个>
You can read more about FrameLayout
here : FrameLayout/Android Developers
这篇关于为什么 FrameLayout 用于片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!