新控件ConstraintLayout、FlexboxLayout快速使用

ConstraintLayout:
(1)导包
compile ‘com.android.support:appcompat-v7:25.0.1’
类名:
android.support.constraint.ConstraintLayout
(2)属性介绍
一、位置控制
子控件的属性:

(1)8个边界约束属性可以固定View的最左边、最右边、最上面、最下面的位置
app:layout_constraintLeft_toLeftOf
app:layout_constraintLeft_toRightOf //我最左边的位置 在别人的右边 下面的意思类似
app:layout_constraintRight_toRightOf
app:layout_constraintRight_toLeftOf app:layout_constraintTop_toTopOf
app:layout_constraintTop_toBottomOf
app:layout_constraintBottom_toBottomOf
app:layout_constraintBottom_toTopOf

(2)通过设置偏移属性,可以控制View在边界范围移动,最左边是0,最右边是1,中间是0.5:

layout_constraintHorizontal_bias(水平方向偏移)(范围0-1)
layout_constraintVertical_bias(垂直方向偏移)(范围0-1)  

二、大小控制

layout_constraintHorizontal_weight //水平方向上比重,类似线性布局
layout_constraintVertical_weight //垂直方向上比重,类似线性布局

1.实现水平方向线性布局,所有的View都必须设置左右边界控制属性,而且相互控制
2.实现比重大小控制,必须设置layout_width=”0dp”重点内容

FlexboxLayout
根布局:xmlns:app=”http://schemas.android.com/apk/res-auto”

app:flexDirection=”column”
app:flexWrap=”wrap”
app:justifyContent=”center”
app:alignItems=”flex_start”
app:alignContent=”flex_start”

子元素属性:
app:layout_order="3"
app:layout_flexGrow="1"
app:layout_alignSelf="stretch"
app:layout_flexShrink="1"
app:layout_alignSelf="baseline"
app:layout_flexBasisPercent="80%"
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值