I started using Jetpack Compose and I'm very happy with it. I replaced a couple of layouts that where defined in xml by a #Composable function.
When I went back to my Navigation-xml I noticed that the preview inside every screen is done with tools:layout property. And property reference to a layout in xml. Not to an #Composable function.
Is there already a way to reference to a #Composable function from tools:layout in a Navigation xml so that the preview of my entire flow will be visible?
Related
How can I make a design like the image with Jetpack Compose? I searched a lot, but I couldn't get any answer similar to the structure I wanted.
You can try out Romain's newest library
Composable widget for Jetpack Compose that allows to flow text around arbitrary shapes over multiple columns.
to achieve this and much more: https://github.com/romainguy/combo-breaker
How about using a simple Text only, but inside a Box where we can clip the size of the image using modifier!!
Box {
Image(modifier = modifier.clicp(RoundedCornerShape(...)))
Text(...)
}
modifier.clip(...) is something which can do the trick.
You can add Images inside text using AnnotatedString and inLineContent parameter of Text Composable
like How adding ImageSpan in jetpack compose Text
or you can use Box Composable and Clip your image using Modifier.clip(Shape)
I have several composables with a preview in my activity. they take a long time to render, and I only need to check one composable. How do I disable the composable preview in Android Jetpack Compose?
You could use the group attribute in the Preview.
Something like:
#Composable
#Preview(group="Test")
fun test1(){ }
Then in the Preview panel you can select the preview group:
In this way you can select the preview to be displayed.
I know with Navigation Component, you can easily set up your toolbar to work with it (https://developer.android.com/guide/navigation/navigation-ui#create_a_toolbar).
You call setupWithNavController and it all magically happens. Then, you get a back arrow whenever you aren't at the start destination.
I am currently working with Jetpack Compose and I'm still new to it. I'm trying to see if navigation component is able to do something similar with the TopAppBar in a Scaffold.
Is there an easy way to set up the nav component with the TopAppBar, or do my navigation icons (back arrows) need to be done manually (call navController.popBackStack as the onClick for these icons)?
In compose, as of compose 1.0.1, at least, you must manually implement it. For a complete understanding, check out this codelab. People are trying to make coding as easy as possible. If it could be automatically done, what you're asking for, it would have been the recommended way in the official codelab, but it isn't. You can file a feature request though.
I wanted to animate my image logo from Screen A to Screen B. In XML based layouts it was possible using windowContentTransitions & transitionName. So I wanted to ask is something similar available in Jetpack Compose?
I have already seen this https://github.com/mobnetic/compose-shared-element
But, Is there something in-built functionality similar to the XML?
Not supported yet by compose. See this conversation on kotlin-lang: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1616517641495500?thread_ts=1616516302.494300&cid=CJLTWPH7S
Updated to Jetpack Compose a-08 today and have a problem. In previous builds I used weight modifier, but now i can't find it. What happened or what is the alternative? In changelogs I founded no information about it.
You can still find it there, but the weight modifier is a extension function inside RowScope and inside ColumnScope, which means you can only use it inside a Column or a Row.
Reference to RowScope: https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/RowScope#weight
Reference to ColumnScope: https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/ColumnScope#weight