Android ConstraintLayout总结
来源:互联网 发布:软件注册码 编辑:程序博客网 时间:2024/05/17 13:07
参考文章: 为什么ConstraintLayout代替其他布局?
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="cn.sofya.testconstraintlayout.MainActivity">
<View
android:id="@+id/view"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@color/colorPrimary"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
</android.support.constraint.ConstraintLayout>
设置控件大小: android:layout_width 和 android:layout_height
有以下几种值: 1. 自适应 0 2:指定大小: 如 100dp 3. match_parent 4. wrap_content
约束组合条件:
1. 与上层或其他对象对应关系
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="@id/view1"
这种形式列表如下:
layout_constraintLeft_toLeftOf
layout_constraintLeft_toRightOf
layout_constraintRight_toLeftOf
layout_constraintRight_toRightOf
layout_constraintTop_toTopOf
layout_constraintTop_toBottomOf
layout_constraintBottom_toTopOf
layout_constraintBottom_toBottomOf
layout_constraintBaseline_toBaselineOf
layout_constraintStart_toEndOf
layout_constraintStart_toStartOf
layout_constraintEnd_toStartOf
layout_constraintEnd_toEndOf
2. 指定间隙
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
3. 设置比例
app:layout_constraintVertical_bias="0.2"
app:layout_constraintHorizontal_bias="0.3"
4.引导线
<android.support.constraint.Guideline
android:id="@+id/guideLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="72dp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Guide Up"
app:layout_constraintStart_toStartOf="@id/guideLine"
app:layout_constraintTop_toTopOf="@+id/constraintLayout"
app:layout_constraintBottom_toBottomOf="@+id/constraintLayout"
app:layout_constraintVertical_bias="0.25"/>
未完。。。。
- Android ConstraintLayout总结
- ConstraintLayout总结
- Android ConstraintLayout
- Android ConstraintLayout
- Android ConstraintLayout
- Android ConstraintLayout
- Android ConstraintLayout
- ConstraintLayout学习总结
- ConstraintLayout 使用总结
- 了解使用Android ConstraintLayout
- 探索Android ConstraintLayout布局
- 了解使用Android ConstraintLayout
- 了解使用Android ConstraintLayout
- 了解使用Android ConstraintLayout
- 了解使用Android ConstraintLayout
- Android ConstraintLayout详解
- Android 之 ConstraintLayout 眯视
- Android ConstraintLayout详解
- SLF4J简介与使用(整合log4j)
- 免费申请SSL证书及搭建HTTPS网站
- 自动部署Ambari到集群的自动化脚本
- gradle的学习与实践记录(一)
- ARKit从入门到精通(1)-ARKit初体验
- Android ConstraintLayout总结
- Jquery 对json的增删改: 查询(遍历)
- AngularJS进阶(五)Angular实现下拉菜单多选
- ARKit从入门到精通(2)-ARKit工作原理及流程介绍
- cnn文本分类 --deeplearning4j为例子
- ARKit从入门到精通(3)-ARKit自定义实现
- ARKit从入门到精通(4)-ARKit全框架API大全
- C# 反射(一)Type类
- ARKit从入门到精通(5)-ARScnView介绍