Android Weekly Notes #429

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.

  1. 改变theme
<style name="Theme.MyApp"
       parent="Theme.MaterialComponents.DayNight">
    <!-- Other theme attributes -->
</style>
  1. 选择想要在哪个mode (optional)
    因为Android 10之前的设备没有dark mode的系统设置, 所以app可以提供app内的设置, 让用户可以改theme.

这种设置在10+以上的设备上可以让用户覆盖系统设置.

  1. 测试

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

Chrome的方式:
https://developers.google.com/web/tools/chrome-devtools/remote-debugging/local-server#port-forwarding

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

Videos

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容