Android Weekly Issue #429
Dark Theme with MDC
Android 10加了系统设置dark mode.
关于Dark theme的design guide:
https://material.io/design/color/dark-theme.html
如何支持dark mode.
- 改变theme
<style name="Theme.MyApp"
parent="Theme.MaterialComponents.DayNight">
<!-- Other theme attributes -->
</style>
- 选择想要在哪个mode (optional)
因为Android 10之前的设备没有dark mode的系统设置, 所以app可以提供app内的设置, 让用户可以改theme.
这种设置在10+以上的设备上可以让用户覆盖系统设置.
- 测试
Refactoring from LiveData to Coroutines & Flow
LiveData只和UI层面有关系, 其他层都不应该使用LiveData. 包括Repository, DataSource, 在这些地方应该使用Flow或者RxJava, 让LiveData只在ViewModel中.
本篇文章讲了如何把Repository中的LiveData改成协程Flow.
用到了livedata-ktx
, 迁移过程中还用到了@deprecated
.
Animating your Keyboard (part 1)
Animating your keyboard (part 2): Reacting to WindowInset animations
键盘动画.
用了Android 11的API, 例子:
https://github.com/android/user-interface-samples/tree/master/WindowInsetsAnimation
Material Motion with MDC
The motion system: https://material.io/design/motion/the-motion-system.html
Port forwarding for Android app development
设备端口转发.
adb的方式:
adb reverse tcp:8085 tcp:8080
Introducing Constraint Layout 2.0
ConstraintLayout 2.0.
Understanding Jetpack Compose — Part 1 of 2
Under the hood of Jetpack Compose — part 2 of 2
了解Jetpack Compose.
Shrinking a Kotlin binary by 99.2%
这个工具可以看dependency tree的diff: https://github.com/JakeWharton/dependency-tree-diff
We Recommend Material Design Components
建议使用Material Design Components.
本期还有好几篇文章:
Code
- https://github.com/airbnb/Showkase 基于注解处理器的Jetpack compose UI分析器.
- https://github.com/JakeWharton/diffuse 各种apk, jar, aar, aab包的diff工具.
- https://github.com/material-components/material-components-android-compose-theme-adapter 让xml中定义的theming可以在jetpack compose中复用.
- https://github.com/JakeWharton/dependency-tree-diff
- https://github.com/android/compose-samples
网友评论