What is the difference between linear and relative

2019-03-16 08:27发布

What is the difference between linear and relative layout?

9条回答
祖国的老花朵
2楼-- · 2019-03-16 08:32

difference is simple: in LinearLayout we arrange stuff in linear manner (one after another), and in RelativeLayout we can place stuff anywhere on screen.

=> Linear Layout is arranged as a list. Rest they are similar in functionality.

查看更多
一纸荒年 Trace。
3楼-- · 2019-03-16 08:34

Linear Layouts

  1. Linear Layouts are great for aligning views in rows and columns.
  2. They are a good way to divide up one place using layout weights that will expand or shrink views depending on the size of the Display.

Relative Layouts

  1. Relative Layouts are great for positioning elements relative to one another.
  2. For example putting B below A or putting C in the lower left hand corner.Check the Screen shoot
  3. Relative layout also make it easy to overlap views. For Example : view A is overlapping view B. Check the Screen-Shoot
查看更多
Explosion°爆炸
4楼-- · 2019-03-16 08:35

The difference between linear and relative layout in android is that in linear layout, the "children" can be placed either horizontally or vertically, but, in relative layout, the children can be placed with relative distance from each other. This is the difference between linear and relative layouts.

查看更多
我只想做你的唯一
5楼-- · 2019-03-16 08:40

Linear layouts put every child, one after the other, in a line, either horizontally or vertically. With a relative layout you can give each child a LayoutParam that specifies exactly where is should go, relative to the parent or relative to other children.

查看更多
小情绪 Triste *
6楼-- · 2019-03-16 08:42

In the relative layout ,all the content in the layout page is related to other contents in the example_layout.xml page

In the case of Linear Layout the elements are displayed in the linear format

查看更多
狗以群分
7楼-- · 2019-03-16 08:49

One of the characteristic feature of LinearLayout in Android is use of a property called Weight, which app can specify using android:layout_weight. This attribute assigns an "importance" value to a view in terms of how much space it should occupy on the screen.

On the other hand, RelativeLayout do not support weight or in other words, RelativeLayout does not pay attention to android:layout_weight. That's a property of LinearLayout.LayoutParams, but not of RelativeLayout.LayoutParams.

查看更多
登录 后发表回答