• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to make image fit in scrollable column?

Resolved: How to make image fit in scrollable column?

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

What I want: I want every image to fit as much as it can in the scrollable column. so the image fit the maximum width it can and the height respectively. I can’t figure out how to do this in compose.
What I tried: I only succeed to do this by using a fixed size for the image but this isn’t really a solution.

Answer:

If you want the Image composable to fill the maximum width available you have to use Modifier.fillMaxWidth(). That is the same with any Composable.
And then if you also want the image content to be scaled in such a way that it fills the maximum width first and then proportionally fills the height as well, you have to pass the ContentScale.FillWidth value for the contentScale parameter.
Both together in your code
Another detail that I noticed, if you want the Button below the Column to actually stay on the screen (and not get pushed out by the Column) you have to add the .weight(1f, fill = true) modifier to the Column.

If you have better answer, please add a comment about this, thank you!

android android-jetpack-compose
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: The ‘Access-Control-Allow-Origin’ header contains multiple values ‘*, *’, but only one is allowed. cors error not resolving

02/04/2023

Resolved: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘crm.email’ doesn’t exist (Connection: mysql, SQL: select count(*) as aggregate from `email`

02/04/2023

Resolved: Regex: Curly braces in reverse? Match X characters before a string?

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.