https://kotlinlang.org logo
#compose
Title
# compose
g

Garret Yoder

03/11/2024, 6:11 PM
Is there any good example of the M3 SearchBar/DockedSearchBar anyone knows off hand that I could read through? It seems like it just kind of floats on top and doesn't have much layout control so I'm wondering if it's just me not having used it before, or if it's really that alpha still and I should just do the search bar from scratch. I guess I was expecting things like integration with scaffold and topappbar behaviors, etc. it also seems like the documentation for it on the android dev site doesn't exist yet.
j

Joel Denke

03/11/2024, 7:05 PM
DockedSearchBar is input field and intend bake result under input field. Its not alpha from what I recall. I used in production for a while. SearchBar is the one you want if using Scaffold, just put inside topAppBar slot. I dont know why the documentation is gone.
g

Garret Yoder

03/11/2024, 7:06 PM
SearchBar in the topappbar slot doesn't respect padding anywhere, it just kind of floats overtop of everything.
j

Joel Denke

03/11/2024, 7:15 PM
Not sure I follow. But can use it without Scaffold as well. In general I think they designed for full screen search where they in use. I think padding is from input field if remember correct. I have used it in Scaffold even if not intended as so. I do agree the difference between search bars is diffuse.
g

Garret Yoder

03/11/2024, 7:15 PM
Are you sure you're using the same search bar? The M3 one is still very much alpha, it requires
@OptIn(ExperimentalMaterial3Api::class)
My biggest gripe is it completely ignores padding/insets/etc. It just seems to position itself ontop of the entire view stack nomatter where in the hierarchy you put it.
j

Joel Denke

03/11/2024, 7:16 PM
It was released in compose M3 1.1.0 release. A lot of things using experimental existing long time. I ignore experimental flags.
Sounds odd if it place itself floating. Sounds like a bug.
5 Views