约束布局ConstraintLayout的使用(一)
来源:互联网 发布:多约束遗传算法matlab 编辑:程序博客网 时间:2024/06/06 00:01
ConstraintLayout是一个ViewGroup,可用作支持库,您可以在从API级别9(Gingerbread)开始的Android系统上使用。
RelativeLayout 和 ConstraintLayout 有许多类似的地方。你可以相对地放置你的子视图,这第一眼看起来和 ConstraintLayout 实现的一样。但RelativeLayout 有一些你可能早就知道的问题。
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" android:layout_alignParentBottom="true" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_marginBottom="34dp" android:layout_marginEnd="24dp" android:layout_marginRight="24dp"/></RelativeLayout>
上面的代码在容器的右下方放了一个按钮
如果把RelativeLayout的layout_height改成wrap_content,按钮就直接在容器的底部。
如果使用ConstraintLayout就可以避免这个问题
<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto"> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" android:layout_marginBottom="34dp" android:layout_marginEnd="24dp" android:layout_marginRight="24dp"/></android.support.constraint.ConstraintLayout>
具体使用请看下一篇:
约束布局ConstraintLayout的使用(二)
阅读全文
0 0
- 约束布局ConstraintLayout的使用(一)
- 约束布局ConstraintLayout的使用(二)
- Android ConstraintLayout 约束布局(一)
- ConstraintLayout约束布局的概念与使用
- 使用约束布局(ConstraintLayout)构建灵活的UI
- 使用约束布局(ConstraintLayout)构建灵活的UI
- ConstraintLayout约束布局使用教程难点理解
- constraintLayout简单但强大的约束布局
- ConstraintLayout(约束布局)中文文档
- ConstraintLayout (约束布局)属性详情
- Android ConstraintLayout 约束布局
- Android ConstraintLayout约束布局
- ConstraintLayout(约束布局)
- ConstraintLayout约束布局
- ConstraintLayout(约束布局)
- Android ConstraintLayout 约束布局
- Android约束布局ConstraintLayout
- 关于约束布局Constraintlayout
- Android Studio:64K问题com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
- 熵值法
- 光环国际PMP:如何成为团队的佼佼者
- 关于中文乱码问题总结----java
- c语言实现插入排序
- 约束布局ConstraintLayout的使用(一)
- 欢迎使用CSDN-markdown编辑器
- MySQL 第六天
- linux上安装使用RabbitMQ
- VBA自定义数据类型(结构体使用)
- 对super函数的简单理解
- Tyvj1009
- 3D迷宫及路径效果展示图
- Windows下bat脚本自动发邮件