is there any online playground for jetpack compose? where I can test and learn jetpack compose. Like https://play.kotlinlang.org
Android studio is not lite. It takes time for setting up projects. Every little practice takes lots of time. If there is an online playground, it will be very help full. Thanks.
While there is no online playground where you can try it in a web browser, there is playground projects that you can clone from Github.
Here's one:
https://github.com/hitherejoe/ComposeAcademy-Playground
You can clone the project, open it and start experimenting with the #Preview annotation or by extending the existing samples.
I have been studying Android for two years, and now I am completely confused about the hierarchy of AndroidX libraries.
To be more concrete: We have AndroidX, Jetpack and Jetpack Compose libraries.
How are they related?
In Jetpack Compose, I've seen packages from AndroidX and vice versa.
androidx is a namespace that include the Android Jetpack libraries, and Compose is just one of them.
The first line of AndroidX Overview docs :
The androidx namespace comprises the Android Jetpack libraries.
And when you use a compose dependency you can see the namespace, e.g. androidx.compose.foundation:foundation.
I'm trying to find the official Android Compose documentation, but I can't find it.
I'm looking for something like the Flutter docs.
What I need is to know the properties of the components and how to use them, something like the Flutter documentation.
The Jetpack Compose documentation can be found at https://developer.android.com/jetpack/compose
The documentation for all the classes is here and you can find a list of packages here.
Since you mention components and how to use them, the functions in the material library are probably most relevant to you. There's also a tutorial that demonstrates some basic usage.
I'm a little confused about the advantages and disadvantages of using Android KTX vs Anko. Because both libraries are trying to achieve the same end goal, and the line between them it's getting a little bit blurry to the point, in some cases, the same functionality is available in both libraries.
I will be very thankful if you help me to clarify the mission of each one, and their use cases.
Thanks in advance!
Anko is a project JetBrains started while developing Kotlin and making it relevant for Android. I'd qualify it as an early production-ready showcase of Kotlin possibilities.
Anko is well known for Anko layouts, but also has some extensions for Android development in Anko Commons, and also a few other modules like SQLite.
However, Anko libraries have accumulated a significant number of methods updates after updates, which today make the library relatively heavyweight when you are limited to 65K methods per dex file (I prefer staying with a single one, for apk size and performance reasons).
Anko commons provides extensions for Android, so it's similar to Android KTX in a way, but it's not as well integrated and organized (packages and artifacts wise) as Android KTX which is now part of AndroidX, which is part of Android Jetpack. Making the libraries smaller, and more loosely coupled is part of the Android Jetpack / Android X philosophy BTW.
So Android KTX, is clearly the future, and I see no reason to not jump in the ship, or rather, not letting it jump in your Android projects.
Also, as you yourself pointed out, future Anko versions will deprecate (and probably finally remove) overlap with Android KTX, to provide only features that are not in AndroidX.
Includes a shameless plug:
Since you're talking about Anko, if Anko layouts got your attention, but you experienced struggles with them (especially when interacting with custom or third-party views), I'd recommend you to check out Views DSL in Splitties, which is more flexible than Anko layouts, and very lightweight. The other modules may also interest you. I started this project to leverage Kotlin features in my Android projects at work and at home.
You've not asked about it, but here's my take on Anko coroutines:
I find the bg { … } extension confusing. I prefer to use kotlinx.coroutines with the Android artifact, using launch, withContext, etc, along with Dispatchers.IO.
However, the Anko coroutines listeners (e.g. onClick that can suspend) are not a bad idea IMO.
Anko is a Kotlin library from JetBrains. It shares the goals with Android KTX of making your life as an Android developer easier and making your code more readable and pleasant to use. Android KTX and are Anko are similar but not quite the same.
Differences Between Anko and Android KTX
They have common goals but with different scopes in mind. The mission of KTX is to bring idiomatic APIs to Kotlin users. KTX does not intend to add new functionality to the existing Android APIs.
Anko has a wider scope, and this gives it the flexibility to innovate and create new features
Deciding When to Use Anko or Android KTX
Generally speaking, Anko and Android KTX cover different parts of the Android API, and there’s no reason you can’t use both in your project. Investigate each one individually and use either as much as you want in your projects!
I am looking for a collapsible view similar to the one shown here
What will be the best approach?
This is the closest I found https://github.com/traex/ExpandableLayout
Want to confirm I am not missing any built in support for such layout?
There is a sample project in github
https://github.com/tjerkw/Android-SlideExpandableListView
Which is under Apache License 2.0
You can modify this project as your requirement and use it in your application