Where is weight (in jetpack compose)? - android

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

Related

Adaptative row in jetpack compose

I have this figma layout to do:
Image here
I already have the chips layout done.
Those chips shows a list of strings.
But I don't know how to get that adaptative row, that when the string are to big, the line break and keep showing in another line.
Can you guys help me please?
Accompanist library has flow layouts that do exactly that: https://github.com/google/accompanist/tree/main/flowlayout
There are also similar flow layouts in the official compose foundation library that were just recently merged, but those are only available as snapshot builds for now.

Android Jetpack Compose text that starts next to the image and continues below it

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)

Is there a way to set auto refresh the jetpack compose preview?

I just started to use the Jetpack compose toolkit. I added the #Preview and a set showBackground = true, showSystemUi = true as parameters and it works really good. But every time i add or change something it doesn't auto refresh by itself, so i have to do it manually.
as Raul text, padding and some other things update automatically, but **
make sure you have live edit of literals on
**.
But soon Live edit of composables, not just literals (Int, String, Dp...) will be available, :
read more here
for the static resources like text, color the UI updates automatically, as it does on the running application, but for the structural components you need to rebuild the project and the changes apply automatically in the preview as well.
Some Components auto-refresh on version 1.1.1

How to display layout in Jetpack Navigation when using Compose?

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?

Android: Need help setting view alignment in code

I basically want to have several views aligned with each other using a relative layout. I can do so using xml, but unfortunately I can't find any documentation that tells me what methods I need to call to get the same effect in code (All the examples and things just use xml). Since the imageviews are being made dynamically xml isn't an option for what I want to do. I've looked at layoutparameters which seems to let me change some options, but I'm not seeing a method that will let me change alignment relative to another view. Any help is appreciated.
After playing around with it some more found that addRule is the method I need. Couldn't find it because I was looking for something with the term alignment in it.
Check out setLayoutParams in the Android documentation:
https://developer.android.com/reference/android/view/View.html#setLayoutParams(android.view.ViewGroup.LayoutParams)

Categories

Resources