Android layout布局(1)

Android的开发常见的4种布局

此次只记录两种:

1,LinearLayout(线性布局)

特点:

           ⑴属性取向可设置两种布局的方式,一种是垂直分布(垂直),另一种是水平分布(水平),

                                                                       orientation =“vertical”          orientation =“horizo​​ntal”

           ⑵当父元素的android:orientation="vertical",layout_gravity的值设置左右的才有效;

               当父元素的android:orientation="horizontal",layout_gravity的值设置上下的才有效。

           ⑶ 首先声明只有在Linearlayout中,layout_weight属性才有效。
                           它是用来指定(剩余空闲空间)的分割比例,而非按比例分配整个空间。 
                           另外android:layout_weight会引起争议,是因为在设置该属性的同时,
                           设置android:layout_width为wrap_content和match_parent会造成两种截然相反的效果。
                           如果想用layout_weight平均分配空间,正确方式是将layout_width(或layout_height)设置为0dp,
                           再通过layout_weight按比例分配空间
                           注:关键点在于搞清楚什么是剩余空闲空间

2、帧布局(FrameLayout)

      该布局过于简单,所以一句话概括:有一种一层一层叠在一起的感觉。

猜你喜欢

转载自blog.csdn.net/qq_41097820/article/details/83116512