preface
In February, Google released the first Beta version of JetPack Compose, which is composed for the first time.
To be honest, when I first heard Compose, I was stunned and thought, what the hell is that? Stop it! You can’t learn anymore!
I thought Compose was an extension of the JetPack suite, like Arch and Lifecycle, so I looked at the throwline teacher’s introductory video and found that it wasn’t easy…
Wow, Google wants to revolutionize Android interface development!
This is my first reaction, so awesome, must learn ah!
What is a composer?
Let’s take a look at Google’s official introduction
Jetpack Compose is a new Android toolkit for building native interfaces. It simplifies and speeds up interface development on Android. Use less code, powerful tools, and an intuitive Kotlin API to make your application lively and exciting quickly.
Less code
You can do more with less code, and you can avoid all kinds of bugs, which makes your code concise and easy to maintain.
intuitive
You just describe the interface, and Compose takes care of the rest. When the application status changes, the interface is automatically updated.
Speed up application development
Compatible with all existing code, easy for you to use anytime, anywhere. Fast iteration with live preview and full Android Studio support.
powerful
Create beautiful apps with direct access to Android platform apis and built-in support for Material Design, dark themes, animations, and more.
Let me add my personal understanding
-
Responsive programming
Broke the previous layout declaration, and then bind data mode, declare View binding data, data update, View will automatically update, and through the diff algorithm to achieve minimal update
-
The code is simple
Instead of using XML to describe a layout and binding data through Kotlin, all layout description and data binding is now done in Kotlin
-
A high performance
Because you don’t need to parse XML, performance is faster, and Compose has redesigned the measurement, layout, and drawing process of the View, effectively reducing the number of measurements and making nesting a thing of the past
-
Cross-platform (not implemented yet)
The design of Compose’S API is more like a variant of Flutter than a platform, so I see a future for Compose!
In actual combat
The Compose code is implemented entirely through Kotlin and uses a large number of Kotlin features, so Compose only supports Kotlin.
Do you still believe Dad Google when he says he won’t give up Java? It’s all lies!
Download the latest Version of Android Studio Preview, and don’t worry about instability. The Preview version can coexist with the official version. On Mac, you can drag the Preview version directly to the application, and a Preview version icon will appear on the LaunchPad.
Download address: developer.android.com/studio/prev…
New a Project and select Empty Compose Activity
The IDE automatically adds the dependencies that Compose requires
Then you can happily coding ~
case
I spent two months using Compose to create a “play Android” client in my spare time to complete the following functions
- Login and registration
- Rank, ranking, points, collection
- Home page, Search
- square
- The public,
Download experience
Raw.githubusercontent.com/wangchenyan…
Part of the screenshot
The specific code is not here to talk about, you can directly look at the source code
Github.com/wangchenyan…
The principle of
This paragraph is left blank because I don’t know 😠yet, so I’ll write 🚩 first
Also hope to have a study of the great god to share, take me
conclusion
The paper come zhongjue shallow, and must know this to practice
This is the philosophy I always follow when learning new knowledge, because I find that after many attempts to “dabble”, it is always forgotten within two days, so either do not learn, or learn to practice, but also leave something for their subsequent need to refer to.
Compose Compose Compose Compose Compose Compose Compose Compose Compose Compose Compose Compose Compose Compose Compose Compose If you think this article useful, but also hope to like, favorites support!