一、简介 Google 2018 IO 大会推出了 Android新的扩展库 AndroidX,用于替换原来的 Android扩展库,按照官方文档说明 AndroidX 是对 android.support.xxx...四、AndroidStudio自动转换 AS 3.2 及以上版本提供了更加方便快捷的方法一键迁移到 AndroidX。选择菜单上的ReFactor —— Migrate to AndroidX......可以在新建工程时就配置好AndroidX。...属性变更 AndroidX对某些组件的属性做了调整,比如FloatingActionButton,切换到AndroidX后,可能会出现解析失败,需要删除一些属性或者调整一些属性。...PS:更多信息请参考AndroidX官方文档
不知从什么时候开始,总是会时不时听到AndroidX这个名词,这难道又是什么新出技术吗?相信有很多朋友也会存在这样的疑惑,那么今天我就来写一篇科普文章,向大家介绍AndroidX的前世今生。 ?...*下面的,而AndroidX库中所有API的包名都变成了在androidx.*下面。这是一个很大的变化,意味着以后凡是android....吸取了之前命名规则的弊端,AndroidX所有库的命名规则里都不会再包含具体操作系统API的版本号了。比如,像appcompat-v7库,在AndroidX中就变成了appcompat库。...一个AndroidX完整的依赖库格式如下所示: implementation 'androidx.appcompat:appcompat:1.0.2' 了解了AndroidX是什么之后,现在你应该放轻松了吧...因此,AndroidX上手起来也没有任何困难的地方,比如之前你经常使用的RecyclerView、ViewPager等等库,在AndroidX中都会有一个对应的版本,只要改一下包名就可以完全无缝使用,用法方面基本上都没有任何的变化
优化:通过 chains 实现等分布局:androidx.constraintlayout.widget.ConstraintLayout> androidx.constraintlayout.widget.ConstraintLayout> androidx.constraintlayout.widget.Guideline...使用 Barrier 处理动态内容当视图尺寸动态变化时,Barrier 可以自动调整约束边界:androidx.constraintlayout.widget.ConstraintLayout>...-- 优化后:单层 ConstraintLayout -->androidx.constraintlayout.widget.ConstraintLayout> androidx.constraintlayout.widget.ConstraintLayout>层级从 3 层降为 1 层,测量时间减少约
gradle 引入 引入 constraintlayout 库 implementation 'androidx.constraintlayout:constraintlayout:1.1.3' constraintlayout...使用 在 layout 中使用android.support.constraint.ConstraintLayout,如下示例 androidx.constraintlayout.widget.ConstraintLayout...-- child view layout --> androidx.constraintlayout.widget.ConstraintLayout> style中新建一个样式,方便后面操作 <...的(0,0)位置 androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/c1" android:layout_width...androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/c2" android:layout_width="match_parent
简介 约束布局ConstraintLayout 是一个ViewGroup,可以在Api9以上的Android系统使用它,它的出现主要是为了解决布局嵌套过多的问题,以灵活的方式定位和调整小部件。...ConstraintLayout减少层级从而提升渲染的时间。 还有一点就是ConstraintLayout可以按照比例约束控件位置和尺寸,能够更好地适配屏幕大小不同的机型。...除了这种偏移外,ConstraintLayout还提供了另外一种偏移的属性: layout_constraintHorizontal_bias 水平偏移 layout_constraintVertical_bias...当ConstraintLayout为1.1版本以下时,使用这些属性需要加上强制约束,如下所示: app:constrainedWidth=”true” app:constrainedHeight=”...true” 使用 0dp (MATCH_CONSTRAINT) 官方不推荐在ConstraintLayout中使用match_parent,可以设置 0dp (MATCH_CONSTRAINT) 配合约束代替
:material:1.5.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.3' testImplementation...> androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk...layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> androidx.constraintlayout.widget.ConstraintLayout...match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> androidx.constraintlayout.widget.ConstraintLayout...name="student" type="kim.hsl.databinding_demo.Student" /> androidx.constraintlayout.widget.ConstraintLayout
> androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res...layout_height="wrap_content" app:layout_constraintTop_toBottomOf="@+id/tab_layout" /> androidx.constraintlayout.widget.ConstraintLayout...; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentPagerAdapter...> androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk...layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> androidx.constraintlayout.widget.ConstraintLayout
kim.hsl.coroutine" } dataBinding { enabled = true } } 在 布局文件 中 , 选中根组件 , 一般是 androidx.constraintlayout.widget.ConstraintLayout...> androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/...-- 布局主要内容 --> androidx.constraintlayout.widget.ConstraintLayout> 使用 " Alt + 回车 " 快捷键 , 弹出如下下拉菜单 ,...-- 布局主要内容 --> androidx.constraintlayout.widget.ConstraintLayout> 设置完毕后 , 先构建应用 , Android...name="viewmodel" type="kim.hsl.coroutine.MainViewModel" /> androidx.constraintlayout.widget.ConstraintLayout
:material:1.5.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.3' testImplementation...schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"> androidx.constraintlayout.widget.ConstraintLayout...layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"/> androidx.constraintlayout.widget.ConstraintLayout...name="student" type="kim.hsl.databinding_demo.Student" /> androidx.constraintlayout.widget.ConstraintLayout...layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> androidx.constraintlayout.widget.ConstraintLayout
$Measurer.measure(ConstraintLayout.java:811) at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.measure...(BasicMeasure.java:372) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.measure(...ConstraintWidgetContainer.java:120) at androidx.constraintlayout.widget.ConstraintLayout.resolveSystem...(ConstraintLayout.java:1594) at androidx.constraintlayout.widget.ConstraintLayout.onMeasure_Original...(ConstraintLayout.java:1708) at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java
的布局编辑器也提供了对ConstraintLayout完善的编辑支持。...ConstraintLayout简介 ConstraintLayout是Google IO 2016引入的一个全新布局Layout,隶属于Jetpack项目(即包含在androidx包里)...,目前release最新版本是1.1.3,在build.gradle里添加依赖即可,如下: implementation 'androidx.constraintlayout:constraintlayout...本篇主要想介绍ConstraintLayout几个强大并且RelativeLayout缺乏的特性,感兴趣的话请往下看。 二. ConstraintLayout新特性 1....而使用ConstraintLayout的话,通过前面介绍的Chain等功能,完全可以在一个ConstraintLayout里实现。
为什么要引入ConstraintLayout 你可能在之前的UI开发中遇到过以下问题: RelativeLayout(以下简称RL)的性能开销较大,而你又很难不使用RL; 想要按比例布局就要使用layout_weight...准备工作 1.1 确保SDK Tools中已经下载了ConstraintLayout(以下简称CL)的支持库: 1.2 gradle中增加对ConstraintLayout的依赖: compile '...com.android.support.constraint:constraint-layout:1.0.2' 1.3 在使用到ConstraintLayout的xml文件头部添加标签: xmlns:...app="http://schemas.android.com/apk/res-auto" 1.4 如果xml能正常联想出ConstraintLayout,并且其子View能正常联想出ConstraintLayout...的相关属性,说明ConstraintLayout已经成功依赖: 2.
> androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res...> androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res...> androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res...> androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res...> androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res
CardView implementation 'androidx.cardview:cardview:1.0.0' TabLayout implementation'com.google.android.material...viewpager implementation 'androidx.viewpager:viewpager:1.0.0' coordinatorlayout implementation'androidx.coordinatorlayout...coordinatorlayout:1.0.0' design ui 库 implementation'com.google.android.material:material:1.0.0-rc01' constraintlayout...约束布局 implementation'androidx.constraintlayout:constraintlayout:1.1.2' NavigationView 侧滑 implementation'com.google.android.material.navigation.NavigationView...:1.0.0' drawerlayout 抽屉布局 implementation'androidx.drawerlayout:drawerlayout:1.0.0' gridlayout 网格布局 implementation'androidx.gridlayout
gridlayout 网格布局 implementation'androidx.gridlayout:gridlayout:1.0.0' drawerlayout 抽屉布局 implementation'androidx.drawerlayout...1.0.0' NavigationView 侧滑 implementation 'com.google.android.material.navigation.NavigationView:1.0.0' constraintlayout...约束布局 implementation 'androidx.constraintlayout:constraintlayout:1.1.2' coordinatorlayout布局 implementation...'androidx.coordinatorlayout:coordinatorlayout:1.0.0' design ui 库 implementation 'com.google.android.material...:material:1.0.0-rc01' swiperefreshlayout implementation 'androidx.swiperefreshlayout:swiperefreshlayout
= { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout"...>androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res...app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" />androidx.constraintlayout.widget.ConstraintLayout...>androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res...layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tv_name" />androidx.constraintlayout.widget.ConstraintLayout
> androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res...layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" /> androidx.constraintlayout.widget.ConstraintLayout...ConstraintSet ConstraintSet 允许你通过代码动态地改变布局约束,以下是一个简单示例: import androidx.constraintlayout.widget.ConstraintSet...import androidx.constraintlayout.widget.ConstraintLayout val constraintLayout: ConstraintLayout = findViewById...androidx.constraintlayout.widget.Barrier android:id="@+id/barrier" android:layout_width="wrap_content
R.anim.fade_in, R.anim.fade_out); image.png 实战 main_acrivity.java: package com.exmple.transition; import androidx.appcompat.app.AppCompatActivity...> androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res...app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> androidx.constraintlayout.widget.ConstraintLayout...> androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res...app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> androidx.constraintlayout.widget.ConstraintLayout
> androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/...layout_height="wrap_content" android:theme="@style/Theme.HelloWorld.AppBarOverlay"> androidx.appcompat.widget.Toolbar...android:layout_marginBottom="16dp" app:srcCompat="@android:drawable/ic_dialog_email" /> androidx.coordinatorlayout.widget.CoordinatorLayout...> androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res...app:layout_constraintTop_toTopOf="parent" app:navGraph="@navigation/nav_graph" /> androidx.constraintlayout.widget.ConstraintLayout
"http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"> androidx.constraintlayout.widget.ConstraintLayout...textView2" app:layout_constraintVertical_bias="0.244" tools:text="Star" /> androidx.constraintlayout.widget.ConstraintLayout..."http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"> androidx.constraintlayout.widget.ConstraintLayout..."http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"> androidx.constraintlayout.widget.ConstraintLayout..."http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"> androidx.constraintlayout.widget.ConstraintLayout
领取专属 10元无门槛券
手把手带您无忧上云