LinearLayout、RelativeLayout 和 AbsoluteLayout 之间有什么区别?
我对 LinearLayout、RelativeLayout 和 AbsoluteLayout 之间的区别感到困惑。 有人可以告诉我它们之间的确切区别吗?
I am confused about the difference between LinearLayout, RelativeLayout, and AbsoluteLayout.
Could someone please tell me the exact differences between them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
LinearLayout
意味着您可以将视图一一对齐(垂直/水平)。RelativeLayout
表示基于其父视图和其他视图之间的关系。ConstraintLayout
与RelativeLayout 类似,它使用关系来定位和调整小部件的大小,但具有额外的灵活性,并且在布局编辑器中更易于使用。WebView
加载 html、静态或动态页面。FrameLayout
将子项加载到另一个之上,就像框架内的卡片一样,我们可以将一个放在另一个之上或框架内的任何位置。已弃用 -
AbsoluteLayout
意味着您必须给出视图应在的确切位置。有关更多信息,请查看此地址 https://developer.android.com /guide/topics/ui/declaring-layout#CommonLayouts
LinearLayout
means you can align views one by one (vertically/ horizontally).RelativeLayout
means based on relation of views from its parents and other views.ConstraintLayout
is similar to a RelativeLayout in that it uses relations to position and size widgets, but has additional flexibility and is easier to use in the Layout Editor.WebView
to load html, static or dynamic pages.FrameLayout
to load child one above another, like cards inside a frame, we can place one above another or anywhere inside the frame.deprecated -
AbsoluteLayout
means you have to give exact position where the view should be.For more information, please check this address https://developer.android.com/guide/topics/ui/declaring-layout#CommonLayouts
定义:
更多信息:
FrameLayout
RelativeLayout
(当前文档此处)
TableLayout
注意:绝对布局已被弃用。
Definitions:
More Information:
FrameLayout
RelativeLayout
(Current docs here)
TableLayout
Note: Absolute Layout is deprecated.
LinearLayout: 将其子级组织成单个水平或垂直行的布局。如果窗口的长度超过屏幕的长度,它会创建一个滚动条。这意味着您可以将视图一一对齐(垂直/水平)。
RelativeLayout: 这使您能够指定子对象相对于彼此的位置(子对象 A 位于子对象 B 的左侧)或相对于父对象的位置(与父对象的顶部对齐)。它基于其父母的观点和其他观点的关系。
WebView:加载 html、静态或动态页面。
有关更多信息,请参阅此链接:http://developer.android.com/指南/topics/ui/layout-objects.html
LinearLayout : A layout that organizes its children into a single horizontal or vertical row. It creates a scrollbar if the length of the window exceeds the length of the screen.It means you can align views one by one (vertically/ horizontally).
RelativeLayout : This enables you to specify the location of child objects relative to each other (child A to the left of child B) or to the parent (aligned to the top of the parent). It is based on relation of views from its parents and other views.
WebView : to load html, static or dynamic pages.
For more information refer this link:http://developer.android.com/guide/topics/ui/layout-objects.html
LinearLayout - 在 LinearLayout 中,视图按垂直或水平方向组织。
RelativeLayout -RelativeLayout 比 LinearLayout 复杂得多,因此提供了更多的功能。顾名思义,视图是相对于彼此放置的。
FrameLayout - 它表现为单个对象,其子视图相互重叠。 FrameLayout 采用最大子元素的大小。
Coordinator Layout - 这是 Android 支持库中引入的最强大的 ViewGroup。它的行为类似于 FrameLayout,并且具有许多在其子视图之间进行协调的功能,例如,浮动按钮和小吃栏、具有可滚动视图的工具栏。
LinearLayout - In LinearLayout, views are organized either in vertical or horizontal orientation.
RelativeLayout - RelativeLayout is way more complex than LinearLayout, hence provides much more functionalities. Views are placed, as the name suggests, relative to each other.
FrameLayout - It behaves as a single object and its child views are overlapped over each other. FrameLayout takes the size of as per the biggest child element.
Coordinator Layout - This is the most powerful ViewGroup introduced in Android support library. It behaves as FrameLayout and has a lot of functionalities to coordinate amongst its child views, for example, floating button and snackbar, Toolbar with scrollable view.
这里有很好的解释:
https://www.cuelogic.com/博客/使用framelayout-for-designing-xml-layouts-in-android
Great explanation here:
https://www.cuelogic.com/blog/using-framelayout-for-designing-xml-layouts-in-android