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

    一天一章
  • 相关阅读:
    epoll 使用详解
    STL 较详尽总结
    可视化对比排序算法
    统治世界的十大算法
    Vector Demo
    Git远程操作(附重要原理图)
    Wireshark(五):TCP窗口与拥塞处理
    Wireshark(四):网络性能排查之TCP重传与重复ACK
    Wireshark(三):应用Wireshark IO图形工具分析数据流
    Wireshark(二):应用Wireshark观察基本网络协议
  • 原文地址:https://www.cnblogs.com/hangman/p/10131744.html
Copyright © 2011-2022 走看看