ConstraintLayout 简单布局可以进行拖拽的方式将控件拖拽到布局中,然后再具体控件进行操作,现在主要是说几个控件一起组成一条链时的操作过程:1、在整条链的第一个条目中设置整条链的样式:app:layout_constraintHorizontal_chainStyle=”spread” ,
其中spread是链的style,具体请参考大神的解析:http://blog.youkuaiyun.com/zxt0601/article/details/726833792、
在链中的每个条目都需要设置两个属性(第一个和最后一个条目除外): app:layout_constraintLeft_toRightOf=”@+id/btn_add_ser” app:layout_constraintRight_toLeftOf=”@+id/contact_salers”
第一条只设置:app:layout_constraintRight_toLeftOf=”@+id/contact_salers”属性
最后一条只设置: app:layout_constraintLeft_toRightOf=”@+id/btn_add_ser”属性
个人觉得在 ConstraintLayout 中还是在xml中编辑出来的界面好一点,因为使用拖拽的时候有可能会出问题,出问题以后整个界面都会乱掉,到时候就欲哭无泪了。
在ConstraintLayout 中使用一些控件和一般使用差不多,之前的android:layout_width=”match_parent” 在ConstraintLayout 中使用android:layout_width=”0dp”
app:layout_constraintRight_toRightOf=”parent”
app:layout_constraintLeft_toLeftOf=”parent”这三句代替,
高度match_parent 用
app:layout_constraintBottom_toBottomOf=”parent” app:layout_constraintTop_toBottomOf=”@+id/头部空间”这些代替
ConstraintLayout 简单实用
最新推荐文章于 2025-03-16 19:20:15 发布