The new Jetpack compose component added to Arch component is like Flutter Ui making.
How does it make the Ui though?
Does it use a native code engine like Skia, or it still follows the ViewGroup way like before?
Jetpack Compose is a modern declarative UI Toolkit for Android. Compose makes it easier to write and maintain your app UI by providing a declarative API that allows you to render your app UI without imperatively mutating frontend views.
Compose for Desktop Features Hardware accelerated rendering with Skia. Powerful text rendering and layout for many languages. Excellent AWT and Swing interoperability. Code sharing with Jetpack Compose Android applications via Kotlin Multiplatform.
Jetpack Compose is Android's modern toolkit for building native UI. It simplifies and accelerates UI development on Android. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs.
remember can be used to store both mutable and immutable objects. Note: remember stores objects in the Composition, and forgets the object when the composable that called remember is removed from the Composition.
Compose creates one view currently named AndroidComposeView
, which inherits ViewGroup, and it draws the widget tree on its canvas. It also processes motion/keyboard events for this view.
There may be more helper views added to this view due to implementation details, but basically for the "widgets" of Compose, you won't see classical Views in view hierarchy. Layout inspector currently doesn't help for Compose - you can try it but you'll won't see your widgets.
Developers are promised to be able to create own customized widgets, which can directly paint on Canvas, set layout for itself or children, or process input events.
However, the Canvas
and lots of other classes used here are not standard framework classes. For example, Canvas for Compose is redefined in Kotlin. Similar way there is new Paint
, Shape
, and other new classes. They internally use framework classes for their work, but that's implementation detail. When drawing, you'd use these new classes.
Since Compose is a library, and not present natively on Android devices, the library is included in each app that uses Compose. Also there is no native code involved here, all is done in Kotlin and becomes part of your app's dexed code. By using Compose, your app won't contain any additional native library (probably, if creators don't change mind).
No, It doesn't use anything from the old UI Toolkit actually they are building it to overcome old UIToolkit's problems.
Compose is not views, It's a new set of Jetpack UI Widget, Basically, it's a Kotlin compiler plugin which renders the Android Canvas (I suppose there's no documentation for this yet) with full compatibility of existing android's view system, the last Dev summit there was a talk covers how it works internally, I/O had another talk too
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With