Android Weekly Issue #429
Dark Theme with MDC
Android 10加了系統(tǒng)設置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的系統(tǒng)設置, 所以app可以提供app內的設置, 讓用戶可以改theme.
這種設置在10+以上的設備上可以讓用戶覆蓋系統(tǒng)設置.
- 測試
Refactoring from LiveData to Coroutines & Flow
LiveData只和UI層面有關系, 其他層都不應該使用LiveData. 包括Repository, DataSource, 在這些地方應該使用Flow或者RxJava, 讓LiveData只在ViewModel中.
本篇文章講了如何把Repository中的LiveData改成協(xié)程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
設備端口轉發(fā).
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