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

Vsevolod Ganin

10/31/2020, 12:38 AM
Is there a way to make a material exposed dropdown menu? I already know composables
DropdownMenu
and
DropdownMenuItem
but I can’t figure what to put in
toggle
to make it look like from design doc. It seems that there should be either
TextField
or
OutlineTextField
but these are very unfriendly when I try to mute their text editing capabilities
d

Doris Liu

10/31/2020, 12:58 AM
Why not put
Text
(with a click listener) in
toggle
, as opposed to
TextField
?
Text
is designed to be read-only, so you don't need to worry about disabling text editing.
v

Vsevolod Ganin

10/31/2020, 1:02 AM
Text
just has no styling.
TextField
on the other hand is from material design and has the styling just what I need
And exposed dropdown menu is implemented using
TextInputLayout
in Material Components for Android by the way. I thought the same logic would apply to Material in Compose
d

Doris Liu

10/31/2020, 1:43 AM
Allowing text input is useful for some use cases like a search box. In your case for styling purposes, I assume
AmbientTextStyle.current
didn't work for you?
v

Vsevolod Ganin

10/31/2020, 2:04 AM
What do you mean?
AmbientTextStyle.current
just contains some text parameters which were provided earlier.
TextField
has its own distinctive values for styling. Besides text parameters,
TextField
declares distinctive paddings, sizes, it positions leading/trailing icons in a way, etc. I just don’t want to implement these specs again for read-only case though it’s perfectly valid option