zoukankan      html  css  js  c++  java
  • 安卓布局ConstraintLayout

    1. android.support.constraint.ConstraintLayout 1.1.x 以上才有百分比属性,否则报错  

    app:layout_constraintWidth_percent="0.5"

    app:layout_constraintHeight_percent="0.5"

    2. ConstraintLayout 要使用app:layout_constraintVertical_bias="0.1" 设置的属性生效,前置条件是设置了top和bottom的约束,app:layout_constraintHorizontal_bias,要设置左右的约束,左右的约束只要设置一个就可以使用了

    app:layout_constraintTop_toBottomOf="parent"
    app:layout_constraintBottom_toTopOf="parent"

    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"


    3.ConstraintLayout如果不是根布局,布局里的子控件的约束不能设置为 "parent",要设置@+id/父控件id(ConstraintLayout)

    Error:(194) error: 'percent' is incompatible with attribute xxx:layout_constraintRight_toRightOf (attr) reference|enum [parent=0].

    4.constraintDimensionRatio 这个一个子控件的宽高约束比例,用法可以这样:

    app:layout_constraintDimensionRatio="4:3"

    app:layout_constraintDimensionRatio="h,4:3"(默认的,不设置为时为H,可以理解为竖屏时的宽高比例)

    app:layout_constraintDimensionRatio="w,4:3"(这个设置时理解为横屏时的宽高比)

    然后在记录一些找到常用的属性

       

    layout_constraintTop_toTopOf       // 将所需视图的顶部与另一个视图的顶部对齐。 


    layout_constraintTop_toBottomOf    // 将所需视图的顶部与另一个视图的底部对齐。 


    layout_constraintBottom_toTopOf    // 将所需视图的底部与另一个视图的顶部对齐。 


    layout_constraintBottom_toBottomOf // 将所需视图的底部与另一个视图的底部对齐。 


    layout_constraintLeft_toTopOf      // 将所需视图的左侧与另一个视图的顶部对齐。 


    layout_constraintLeft_toBottomOf   // 将所需视图的左侧与另一个视图的底部对齐。 


    layout_constraintLeft_toLeftOf     // 将所需视图的左边与另一个视图的左边对齐。 


    layout_constraintLeft_toRightOf    // 将所需视图的左边与另一个视图的右边对齐。 


    layout_constraintRight_toTopOf     // 将所需视图的右对齐到另一个视图的顶部。


    layout_constraintRight_toBottomOf  // 将所需视图的右对齐到另一个的底部。


    layout_constraintRight_toLeftOf    // 将所需视图的右边与另一个视图的左边对齐。


    layout_constraintRight_toRightOf   // 将所需视图的右边与另一个视图的右边对齐。

    一天一章
  • 相关阅读:
    java-五子棋棋盘排布 && 数字转换成汉字 &&大数计算
    动手动脑,无法自拔(2)课时作业4
    动手动脑,无法自拔(1)课时作业3
    《大道至简》 第二章 读后感
    NABCD需求
    第九周总结
    第八周总结
    最大子数组(循环连接)
    第七周总结
    最大子数组和
  • 原文地址:https://www.cnblogs.com/hangman/p/10131744.html
Copyright © 2011-2022 走看看