Questions tagged [android-compose-layout]

30 questions
62
votes
7 answers

Weights in Jetpack compose

Is it possible to do weights in Jetpack Compose? For example, I'd like to set it up in such a way that one item is weighted as 1/3 of a layout, and the other takes up the remaining 2/3. In the XML/ViewGroup style, you can achieve this using…
58
votes
5 answers

Jetpack Compose - Centering Text

I am using Jetpack Compose to create a simple flash card. The idea is that you click the flash card and it will give you the answer. However, I am stuck on a basic problem. Unfortunately... I could not even find the official documentation, so my…
28
votes
5 answers

How to align Text to Top, Bottom and Center Vertically in Jetpack Compose?

How can I align the text using Text composable function vertically. Is there a way to do it without having to add another extra view to contain the Text. The textAlign parameter of Text only has the following…
23
votes
1 answer

How to combine Arrangement.spacedBy() and Arrangement.Center in a Row.horizontalArrangement

Is it possible to combine Arrangement.spacedBy(16.dp) and Arrangement.Center in a Row.horizontalArrangement? What I would like to do is to center the content horizontally and also set a default spacing of 16.dp. I know that I can combine the Row and…
20
votes
2 answers

Jetpack compose code to scroll down to the position of a specific UI element on clicking a Text

I am trying to scroll down to the position of a specific UI element on clicking a Text. The code for my Text is: Text( "What is autosaving?", color = colorResource(id = R.color.text_highlight), …
15
votes
1 answer

How to individually/separately align child composables inside a Row?

I'm new in jetpack compose and I'm trying to do a simple thing that I can't achieve it. That I want to do is in the same row align one component, in this case a surface, at the start and the other one, the column, at the end of the row. How can get…
S.P.
  • 2,274
  • 4
  • 26
  • 57
10
votes
1 answer

Jetpack Compose Constraint Layout constrains not linking

I'm using constrainAs with Jetpack Compose to constrain a list of wifi options to the top of the parent and then to the bottom of a text view. As seen from the photo my list isn't being constrained to the top of the parent or to the textview below…
7
votes
0 answers

Android compose LazyRow inside LazyColumn gives junk behaviour

I am trying to create one compose screen with nested scroll behaviour. For that I am using lazyColumn as parent and inside that I do have multiple rows with layRow. val scrollState = rememberLazyListState() LazyColumn( state = scrollState, …
4
votes
3 answers

Create vertical chain with respect to other element in jetpack compose ConstraintLayout?

I want to chain title and description text centered with respect to image with chainStyle.Packed how to achieve this in jetpack compose. when i use createVerticalChain() its create chain with respect to parent container that's not what i want, is…
4
votes
2 answers

Icons getting disappears if the text is too long in Jetpack Compose

@Composable fun TopAppBar( name: String, modifier: Modifier = Modifier ) { Row( modifier = modifier .fillMaxWidth() .padding(20.dp, 0.dp), verticalAlignment = Alignment.CenterVertically, …
3
votes
2 answers

draw round corners in canvas with drawArc

I'm trying to create a pie chart in Jetpack Compose. I'm trying to make corners round for each Pie in the Chart. But, I'm having issues making corner rounds. I tried using cap = StrokeCap.Round in drawArc in canvas, but did not get any luck making…
3
votes
2 answers

how to align button bottom center in jetpack compose?

I've been trying to align a button in Column from the bottom to the center for a while, but I couldn't succeed. hear is my code: NutritionHabitsScreen @Composable fun NutritionHabitsRoute( navHostController: NavHostController, …
3
votes
1 answer

TextField overflow and softwrap not working with Compose Constraint Layout

I've been trying to build a list with a Card in it formatted like this: The difficulty here is that the title e.g. "Bread" and ingredient name e.g. "Flour" can be very long and thus I want to have an ellipsis to keep things manageable i.e. "My Long…
2
votes
0 answers

How to draw cutout in PreviewView Android Compose?

I'm creating a QR Scanner where the preview view is blur except the centre square part, I was able to blur PreviewView but not able to think of a way to unblur the centre cutout part. AndroidView( modifier = Modifier.fillMaxSize(), …
1
vote
1 answer

How to show semi-transparent loading overlay above full Composable

I am trying to create a Composable that wraps another content Composable and displays a CircularProgressBar as an overlay on top of it, covering the whole content Composable. I almost got it working as wished, see the following to images: Initial…
1
2