Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 143 characters in body; edited title
Source Link
Thracian
  • 70k
  • 22
  • 215
  • 407

Jetpack Compose How to Align text or content of Text component with specific size to bottom left or right?

How can i align text to bottom section of a Text component with Jetpack Compose? TextAlign only has Start, End, Left, Center, Right and Justify options.

I want to align text to bottom left or right, how can this be done with Jetpack Compose?

With it's possible to align it's elements but iI want to align Text components whichcomponent's content, each Text has a specific size using modifier.size(x), to align their text to bottom. In the image blue rectangles are Text with different sizes should align the text inside them like in classic Android with it's done with android:gravity.

What i actually wantIt is similar to textAlign = TextAlign.x but for bottom.

Setting alignment from a boxBox aligns TextText inside box likeBox or Modifier.align(Alignment.BottomEnd) in BoxScope does what android:layout_gravity does for views, aligns the Text component, not the content of Text component, you can see the differencedifference here.

Jetpack Compose How to Align Text to bottom left or right?

How can i align text to bottom section of a component with Jetpack Compose? TextAlign only has Start, End, Left, Center, Right and Justify options.

I want to align text to bottom left or right, how can this be done with Jetpack Compose?

With it's possible to align it's elements but i want to align Text components which each has a specific size to align their text to bottom. In the image blue rectangles with different sizes should align the text inside them like in classic Android with it's done with android:gravity.

What i actually want is similar to textAlign = TextAlign.x but for bottom.

Setting alignment from a box aligns Text inside box like android:layout_gravity does, you can see the difference here.

Jetpack Compose How to Align text or content of Text component with specific size to bottom left or right?

How can i align text to bottom section of a Text component with Jetpack Compose? TextAlign only has Start, End, Left, Center, Right and Justify options.

I want to align Text component's content, each Text has a specific size using modifier.size(x), to align their text to bottom. In the image blue rectangles are Text with different sizes should align the text inside them like in classic Android done with android:gravity.

It is similar to textAlign = TextAlign.x but for bottom.

Setting alignment from a Box aligns Text inside Box or Modifier.align(Alignment.BottomEnd) in BoxScope does what android:layout_gravity does for views, aligns the Text component, not the content of Text component, you can see the difference here.

added 356 characters in body; added 2064 characters in body
Source Link
Thracian
  • 70k
  • 22
  • 215
  • 407

How can i align text to bottom section of a component with Jetpack Compose? TextAlign only has Start, End, Left, Center, Right and Justify options.

I want to align text to bottom left or right, how can this be done with Jetpack Compose?

enter image description here

With it's possible to align it's elements but i want to align Text components which each has a specific size to align their text to bottom. In the image below code for threeblue rectangles with different sizes should align the text inside them like in classic Android with it's done with Textandroid:gravity.

What i actually want is similar to textAlign = TextAlign.x but for bottom.

Setting alignment from a box aligns Text inside box like android:layout_gravity does, you can see the difference here.

enter image description here

Code for the blue rectangles in the image is

i want text to be aligned at the bottom so it's possible to see both Text components and their texts.For orange rectangles

@Composable fun BoxShadowAndAlignmentExample() { Box( modifier = Modifier .fillMaxWidth() .height(250.dp) .background(Color.LightGray) .padding(8.dp) ) { Box( modifier = Modifier.shadow( elevation = 4.dp, shape = RoundedCornerShape(8.dp) ) ) { // This is the one at the bottom Text( text = "First", modifier = Modifier .background(Color(0xFFFFA000)) .size(200.dp), color = Color.White ) } Box( modifier = Modifier.shadow( elevation = 4.dp, shape = RoundedCornerShape(8.dp) ) .align(Alignment.TopEnd) ) { // This is the one in the middle Text( text = "Second", modifier = Modifier .background(Color(0xFFFFC107)) .size(150.dp), color = Color.White ) } val modifier = Modifier.shadow( elevation = 4.dp, shape = RoundedCornerShape(8.dp) ) .align(Alignment.BottomStart) Box( modifier = modifier ) { // This is the one on top Text( text = "Third ", modifier = Modifier .background(Color(0xFFFFD54F)) .size(100.dp), color = Color.White ) } } } 

How can i align text to bottom section of a component with Jetpack Compose? TextAlign only has Start, End, Left, Right and Justify options.

I want to align text to bottom left or right, how can this be done with Jetpack Compose?

enter image description here

With it's possible to align it's elements but i want to align Text components which each has size to align their text to bottom. In the image below code for three Text inside box is

i want text to be aligned at the bottom so it's possible to see both Text components and their texts.

How can i align text to bottom section of a component with Jetpack Compose? TextAlign only has Start, End, Left, Center, Right and Justify options.

I want to align text to bottom left or right, how can this be done with Jetpack Compose?

With it's possible to align it's elements but i want to align Text components which each has a specific size to align their text to bottom. In the image blue rectangles with different sizes should align the text inside them like in classic Android with it's done with android:gravity.

What i actually want is similar to textAlign = TextAlign.x but for bottom.

Setting alignment from a box aligns Text inside box like android:layout_gravity does, you can see the difference here.

enter image description here

Code for the blue rectangles in the image is

For orange rectangles

@Composable fun BoxShadowAndAlignmentExample() { Box( modifier = Modifier .fillMaxWidth() .height(250.dp) .background(Color.LightGray) .padding(8.dp) ) { Box( modifier = Modifier.shadow( elevation = 4.dp, shape = RoundedCornerShape(8.dp) ) ) { // This is the one at the bottom Text( text = "First", modifier = Modifier .background(Color(0xFFFFA000)) .size(200.dp), color = Color.White ) } Box( modifier = Modifier.shadow( elevation = 4.dp, shape = RoundedCornerShape(8.dp) ) .align(Alignment.TopEnd) ) { // This is the one in the middle Text( text = "Second", modifier = Modifier .background(Color(0xFFFFC107)) .size(150.dp), color = Color.White ) } val modifier = Modifier.shadow( elevation = 4.dp, shape = RoundedCornerShape(8.dp) ) .align(Alignment.BottomStart) Box( modifier = modifier ) { // This is the one on top Text( text = "Third ", modifier = Modifier .background(Color(0xFFFFD54F)) .size(100.dp), color = Color.White ) } } } 
added 1472 characters in body
Source Link
Thracian
  • 70k
  • 22
  • 215
  • 407

enter image description here

With it's possible to align it's elements but i want to align Text components which each has size to align their text to bottom. In the image below code for three Text inside box is

@Composable fun BoxExample() { Box( modifier = Modifier .fillMaxWidth() .height(250.dp) .background(Color.LightGray) ) { // This is the one at the bottom Text( text = "First", modifier = Modifier .background(Color(0xFF1976D2)) .size(200.dp), color = Color.White, ) // This is the one in the middle Text( text = "Second", modifier = Modifier .background(Color(0xFF2196F3)) .size(150.dp), color = Color.White ) // This is the one on top Text( text = "Third ", modifier = Modifier .background(Color(0xFF64B5F6)) .size(100.dp), color = Color.White ) } } 

i want text to be aligned at the bottom so it's possible to see both Text components and their texts.

enter image description here

With it's possible to align it's elements but i want to align Text components which each has size to align their text to bottom. In the image below code for three Text inside box is

@Composable fun BoxExample() { Box( modifier = Modifier .fillMaxWidth() .height(250.dp) .background(Color.LightGray) ) { // This is the one at the bottom Text( text = "First", modifier = Modifier .background(Color(0xFF1976D2)) .size(200.dp), color = Color.White, ) // This is the one in the middle Text( text = "Second", modifier = Modifier .background(Color(0xFF2196F3)) .size(150.dp), color = Color.White ) // This is the one on top Text( text = "Third ", modifier = Modifier .background(Color(0xFF64B5F6)) .size(100.dp), color = Color.White ) } } 

i want text to be aligned at the bottom so it's possible to see both Text components and their texts.

Source Link
Thracian
  • 70k
  • 22
  • 215
  • 407
Loading