File tree Expand file tree Collapse file tree 3 files changed +17
-6
lines changed
Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -2,13 +2,22 @@ MaterialDesign使用
22===
33
44- [ Material Design] ( https://material.io/components?platform=android ) 是` Google ` 在` 2014 ` 年的` I/O ` 大会上推出的全新设计语言。
5- - ` Material Design ` 是基于` Android 5.0``(API level 21) ` 的,兼容5.0以下的设备时需要使用版本号` v21.0.0 ` 以上的
6- ` support v7 ` 包中的` appcpmpat ` ,不过遗憾的是` support ` 包只支持` Material Design ` 的部分特性。
7- 为了更好的去使用,需要继承support.design包:
5+ 为了使用Materia功能,首先需要集成相应的依赖:
86```
9- implementation 'com.android.support:design:<version>'
7+ implementation 'com.google.android.material:material:<version>'
8+ ```
9+ 并保证Activity都使用AppCompatActivity,这样可以确保所有组件都能正常使用。
10+ 把主题改成集成自Material组件的主题:
11+ ```
12+ Theme.MaterialComponents
13+ Theme.MaterialComponents.NoActionBar
14+ Theme.MaterialComponents.Light
15+ Theme.MaterialComponents.Light.NoActionBar
16+ Theme.MaterialComponents.Light.DarkActionBar
17+ Theme.MaterialComponents.DayNight
18+ Theme.MaterialComponents.DayNight.NoActionBar
19+ Theme.MaterialComponents.DayNight.DarkActionBar
1020```
11-
1221
1322Material Design Theme
1423---
Original file line number Diff line number Diff line change 3131and first-class delegation`等实现
3232- ` Kotlin ` 可与` Java ` 语言无缝通信。这意味着我们可以在` Kotlin ` 代码中使用任何已有的` Java ` 库;同样的` Kotlin ` 代码还可以为` Java ` 代码所用
3333- ` Kotlin ` 在代码中很少需要在代码中指定类型,因为编译器可以在绝大多数情况下推断出变量或是函数返回值的类型。这样就能获得两个好处:简洁与安全
34+ - Kotlin 是一种静态类型的语言。这意味着,类型将在编译时解析且从不改变
35+
3436
3537## ` Kotlin ` 优势
3638
Original file line number Diff line number Diff line change 33
44## ` if ` 表达式
55
6- 在` Kotlin ` 中,` if ` 是一个表达式,即它会返回一个值。因此就不需要三元运算符` 条件 ? 然后 : 否则 ` ,因为普通的` if ` 就能胜任这个角色。
6+ 在` Kotlin ` 中,` if ` 是一个表达式,即它会返回一个值,每个条件分支都隐式地返回其最后一行的表达式的结果,因此无需使用return关键字 。因此就不需要三元运算符` 条件 ? 然后 : 否则 ` ,因为普通的` if ` 就能胜任这个角色。
77` if ` 的分支可以是代码块,最后的表达式作为该块的值:
88
99``` kotlin
You can’t perform that action at this time.
0 commit comments