【问题标题】:I want to achieve the below layout, the button should be at the bottom of the screen, when the lazy column is filled, the button shouldn't go outsideI want to achieve the below layout, the button should be at the bottom of the screen, when the lazy column is filled, the button shouldn\'t go outside
【发布时间】:2022-12-02 06:17:55
【问题描述】:

There is lazy column at top and below the lazy column there is enter phone number layout and add contact from phonebook layout, I want this layout to be at top when no contact is added and when I add lots of contact the enter phone number and add contact from phonebook layout scrolls along with the lazy column and goes outside of the screen. I don't them to go outside of the screen. They must stick to bottom when there is lots of contact.

【问题讨论】:

  • The ideal is that you put some example code that you have at the moment, so that we can test with it and provide you with a solution. But anyway, I believe that the problem you are having is related to the fact that the LazyColumn tries to occupy all the space below it when a fixed height is not provided, causing the components below to be "off the screen", the best way to handle this is to provide a Modifier.weight(weight = 1F) for your LazyColumn. Remembering that it is only possible to use .weight() if you are within the scope of a Column or Row

标签: android android-studio kotlin android-jetpack-compose android-jetpack-compose-list


【解决方案1】:

You can apply the weight modifier to the LazyColumn.
Something like:

Column(){

    LazyColumn(Modifier.weight(weight = 1f, fill = false)) {
        //....
    }

    Footer()
}

Using fill=false the element will not occupy the whole width allocated.

【讨论】:

  • How would you achieve this, specifically with content below the lazy column, inside a dialog where the dialog height should wrap the lazy column height, based on item count, until it reaches the max allowable dialog height at which point the column should scroll its contents. Currently Modifier.weight(1F) on the lazy column stretches the dialog to max height - not desireable. Not using this weight modifier works and lazy column grows (dialog wraps content), however when item count is above max dialog height content at the bottom is "squashed" - do I need a fixed height for bottom content?
猜你喜欢
  • 2022-12-26
  • 2022-12-30
  • 1970-01-01
  • 2022-12-27
  • 1970-01-01
  • 2022-11-15
  • 2022-12-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多