ConstraintLayout笔记

一、貌似存在的Bug

(1)当父布局为ConstraintLayout时其子控件在网络加载成功动态设置隐藏显示时偶尔会 出现失效的情况,换成其他布局无此问题
(2)用ConstraintLayout嵌套drawerLayout时上面有toolbar下面有bottomNavigation时常规设置drawerLayout占用剩余的高度会报错,用linearLayout+wheight就不会

二、利用它解决一个需求:文本在最右侧显示,超出一行时换行但新换的行从左侧开始

<TextView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="我是超出一行的文本,我要居右且换行后居左"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintHorizontal_bias="1"
       app:layout_constrainedWidth="true"
       app:layout_constraintTop_toTopOf="parent"
       app:layout_constraintStart_toEndOf="@+id/tv_userNameInfo" />

# 关键点是同时设置:
    android:layout_width="wrap_content"
    app:layout_constraintHorizontal_bias="1"
    app:layout_constrainedWidth="true"
# AndroidStudio3.4.2预览貌似有问题但运行正常显示
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容