ConstraintLayout 平分布局
原文链接:https://juejin.im/post/5a31ee3af265da43294e0fe1
添加依赖
compile 'com.android.support.constraint:constraint-layout:1.0.2'
创建布局
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/bt_a"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="scroller_scroll"
android:textSize="12dp"
app:layout_constraintBottom_toTopOf="@+id/button3"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/bt_b"/>
<Button
android:id="@+id/bt_b"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="scroller_fling"
android:textSize="12dp"
app:layout_constraintBottom_toTopOf="@+id/button3"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@+id/bt_a"
app:layout_constraintRight_toLeftOf="@+id/bt_c"/>
<Button
android:id="@+id/bt_c"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="over_scroll"
android:textSize="12dp"
app:layout_constraintBottom_toTopOf="@+id/button3"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@+id/bt_b"
app:layout_constraintRight_toRightOf="@+id/bt_d"/>
<Button
android:id="@+id/bt_d"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="overs_fling"
android:textSize="12dp"
app:layout_constraintBottom_toTopOf="@+id/button3"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@+id/bt_c"
app:layout_constraintRight_toRightOf="parent"/>
<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
/>
</android.support.constraint.ConstraintLayout>
复制代码
需要了解的地方
- 宽度为0dp
android:layout_width="0dp"
- 需要准确指定左右的约束
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/bt_b"//使用@id 编译不通过,使用@+id就可以了
- 指定权重
app:layout_constraintHorizontal_weight="1"
- 约束也可以为
parent
app:layout_constraintBottom_toBottomOf="parent"
转载于:https://juejin.im/post/5a31ee3af265da43294e0fe1
ConstraintLayout 平分布局相关推荐
- 两个LinearLayout或者ConstraintLayout平分布局
两个LinearLayout平分布局如图所示: 代码如下,有需要的可以直接复制粘贴到activity_main.xml,之后可以在布局上增加自己想要的控件 <?xml version=" ...
- Android ConstraintLayout约束布局的使用
前言:回廊一寸相思地,落月成孤,背灯和月花阴,已是十年踪迹十年心. -- 虞美人 一.概述 AndroidStudi ...
- 【约束布局】ConstraintLayout 约束布局 ( 简介 | 引入依赖 | 基本操作 | 垂直定位约束 | 角度定位约束 | 基线约束 )
文章目录 一. ConstraintLayout 简介 1. 引入 约束 布局 ( 1 ) 约束性布局 作用 和 简介 2. 约束 简介 ( 1 ) 约束个数要求 ( 2 ) 约束设置 与 显示位置 ...
- Android入门教程:ConstraintLayout约束布局
原文首发自掘金芦苇APP团队,转载到自己小号上再发一遍~ 翻译By Leelion6.关于 ConstraintLayout 的文章其实已经不少了,不过看到这篇文章写的很有趣,以及在翻译的过程中,感受 ...
- 约束布局ConstraintLayout加快布局速度
Android Studio2.2更新布局设计器,同时,引人了约束布局ConstraintLayout. 简单来说,可以把它看做是相对布局的升级版本,但是区别与相对布局更加强调约束.何为约束,即控件之 ...
- 哲♂学三幻神带你学习ConstraintLayout(约束布局)
一句话概括本文: 本文详细讲述了一波 ConstraintLayout约束布局 的用法,应该涵盖了该布局 所有的用法,有遗漏的欢迎评论区提出- 引言 其实这篇文章呢,是很久之前写的了,不过没发到掘金上 ...
- 【Android】ConstraintLayout约束布局最全解析
ConstraintLayout约束布局最全解析 一.ConstraintLayout概述 二.ConstraintLayout基础篇 2.1 基础操作 2.2 控件间添加约束 2.3 约束布局xml ...
- Android ConstraintLayout约束布局的理解与使用
一.什么是约束布局(ConstraintLayout) ConstraintLayout 是一个使用"相对定位"灵活地确定微件的位置和大小的一个布局,在 2016 年 Google ...
- layout布局_Android ConstraintLayout 降低布局层次,布局优化首选
目录 1. 介绍 2. ConstraintLayout的优点 3. ConstraintLayout使用方法 3.1 Relative positioning(相对定位) 3.2 Margins(边 ...
最新文章
- 用sqlSessionFactoryBeanName而不用sqlSessionFactory的原因
- [转贴]非技术:在广州天河北被抢全记录(入面D广州话真系厉害,不懂粤语者别看,会吐血)...
- 演练 课程导航 1002 html
- Django(九)admin相关知识
- Rabbtmq Confirm 确认消息
- dart map 转list_Dart 集合类型List Set Map循环forEach map where any every
- 开课吧Java面试题:虚引用与软引用和弱引用的区别
- Linux shell脚本详解及实战(五)——shell脚本函数
- 杀软自己做 编写autorun病毒免疫工具
- GBS国标经纬度转高德经纬度
- 集成学习—多算法融合
- 【洛谷】P3537 [POI2012]SZA-Cloakroom
- Android应用源码基于安卓的个人隐私监控项目
- 记录 | KMS工具激活Office报错 Error Code: 0x80080005
- webpack打包时提示:The following entrypoint(s) combined asset size exceeds the recommended limit
- 2023最新苹果CMS10仿电影先生网站自适应源码/UI简约大气极速加载
- 《Multi-Scale Residual Learning-using a Cycle Spinning CNN for Single Image De-Raining》
- 实景三维可视化管理平台助力提升景区运营管理水平
- 大型数据中心互联(T级光传输方案)
- 微博视频处理系统的云原生之路
热门文章
- google的glog日志管理
- vue事件修饰符,六次实操带你快速了解与应用~
- matlab spwm变频调速开环系统电路仿真图,SPWM变频调速系统的原理及仿真模块的建立...
- 清科创业IPO:倪正东和他的投资帝国
- 鸿蒙os2.0电脑版,鸿蒙os2.0系统正式版下载安装-鸿蒙os2.0系统(华为升级)官方最新版下载-战地2中文网...
- goalng 输入账号密码
- Mac设置subl启动sublime text
- iOS上架流程详细版本
- iOS上架详细通关教程
- Tomcat构建企业级高负载WEB服务器