• 安卓布局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   // 将所需视图的右边与另一个视图的右边对齐。

    一天一章
  • 相关阅读:
    javascript 写一个随机范围整数的思路
    Promise中的next 另一个用法
    继上一篇随笔,优化3张以上图片轮播React组件
    低性能3张图片轮播React组件
    用函数式编程思维解析anagrams函数
    Python time time()方法
    torch.view().expand()
    pytorch中的top_K()函数
    设定学习率衰减
    两个集合求交集
  • 原文地址:https://www.cnblogs.com/hangman/p/10131744.html
Copyright © 2020-2023  润新知