前言
在android开发中,我们通常是手写布局,很少会用拖动来写布局,虽然constraintlayout在i/o上以拖动来展现了各种功能,我估计在以后开发中,程序员还是习惯手撸代码。
我自己试着拖着用了一下,用得不是很明白 ,而且用起来效果不是很好。
那么
直接上手撸了一下~~~
其实很简单
button1:app:layout_constraintbottom_totopof="@id/iv_head"
我们把这个属性拆开来看,constraintbottom指的本身的底部,即button1的顶部,totopof是指imageview的顶部,那么这句话的意思就是
aligns the bottom of the desired view to the top of another.(官方原文)
翻译一下就是button1的底部要和imageview的顶部对齐
button1 app:layout_constraintright_toleftof="@id/iv_head"
根据上面的规则我们就知道button1的右边要和imageview的左边对齐。
其实很简单就是说两个view的某个方位要对齐
没了,就这么简单,其它属性可以举一反三,它比relativelayout控制起来更加得以就手。
到此,你已经掌握了一大半的constraintlayout知识点
还有其它的一些属性
app:layout_constraintstart_toendof
意思就是button的开始部分(从左往右看,开始部分就是button的左边)与imageview的右边是对齐的。
app:layout_constraintstart_tostartof
这个就是说button的左边与imageview的左边是对齐的
不知道为什么上面已经出的属性能够满足布局需要了,为什么还要再出start和end的。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对移动技术网的支持。
如对本文有疑问, 点击进行留言回复!!
Xamarin 安卓 相机 各种坑 目标API Android 6以后,我选的目标API版本是 Android 10
Android 9.0+软件某些功能突然暴毙:cleartext not permitted
Android : Resource is not a Drawable (color or path)
Flutter问题集锦——Android Studio 4.0.1 在AVD Manger中启动模拟器报“unable to locate abd”
网友评论