https://kotlinlang.org logo
Title
s

S.

05/01/2022, 12:31 AM
I'm aware that Materials textfields are somewhat large but this looks like I've enabled retiree mode somehow
😂 2
is this really the norm? and if does anybody actually use this?
c

Colton Idle

05/03/2022, 6:45 AM
that does looks larger than im used to. show some code?
I also believe that text fields now have a "condensed" mode where you can make them a bit more compact.
s

S.

05/03/2022, 8:01 AM
OutlinedTextField(value = inputLanguage, onValueChange = { inputLanguage = it }, label = {
            Text(
                stringResource(id = R.string.language)
            )
        })
this is said textfield. I couldn't find anything relevant in the theming files. is there anything you could adjust? for Shapes I only have RoundedCornerShape but that does'nt seem to be it
c

Colton Idle

05/03/2022, 6:24 PM
@Chris Sinco [G] sorry for the ping, but anything you can think of in terms of some CompositionLocal or something?
c

Chris Sinco [G]

05/04/2022, 7:45 PM
I believe we’ll need to look at your code since in both Compose Material2 and Material3, the size of the text field looks to spec, which is the min height set to 56.dp
In theory, the API allows the min height to change through
Modifier.heightIn
(also noted in the source), but that doesn’t seem to work that well since when I use it to set to say 40.dp, the field only shrinks by 3.dp (using Layout Inspector to see the runtime measurements). There’s inner padding in the TextField of 16.dp which doesn’t seem configurable via modifiers, so may be contributing to the size.
@Louis Pullen-Freilich [G] or @Anastasia [G] have any other thoughts on this? May also be case that if one wants a smaller TextField, then rebuilding a custom one with
BasicTextField
is always an option
I also believe that text fields now have a “condensed” mode where you can make them a bit more compact.
@Colton Idle not sure this exists in M3 — it’s certainly not in M2
a

Anastasia [G]

05/04/2022, 8:01 PM
We have an experimental API called TextFieldDecorationBox where you can change the content padding
👀 1
s

S.

05/04/2022, 8:01 PM
I don't know exactly which part of the code I should share with you, I don't remember doing anything special. The text fields looked like this from the beginning afaik. changing the height doesn't really work due to the inner padding eating up the text
I think that partly solves the issue. Using this experimental API (looks like only available in M3) is useful if you are constructing the widget from scratch via BasicTextField, but it can’t be used with the Material component. So seems one does have to recreate it overall if they want it to be more condensed.
s

S.

05/04/2022, 8:40 PM
right, and I ended up making my own since you can't touch the layout or decoration box. but according to the specs https://material.io/components/text-fields#specs there really seems to be something wrong on my end. though in the pictures it doesn't look much smaller than mine. however, red bar here is 56.dp in height
a

Anastasia [G]

05/04/2022, 9:07 PM
I wouldn't say that using this API is the same as constructing the text field from scratch. You essentially get all the functionality, just need to pass this box as a parameter of the basic text field. In the future material team could add part of that functionality into text field directly, but to learn the best shape of it they should be getting feedback about that experimental decoration box API. As for the availability of the API, it was introduced in both M2 and M3
c

Colton Idle

05/04/2022, 9:09 PM
@S. do you have any code to show? Something that minimally reproduces your issue. Kinda hard to help without that.
s

S.

05/04/2022, 9:29 PM
no, I actually don't. because it turned out to be the font I'm using
same typography settings but left is a noto combination and right is google_sans_medium
just checked with the official files from https://fonts.google.com/noto/specimen/Noto+Sans but they are fine. the merged file I'm using seems to be the issue. sorry for bothering everyone
c

Chris Sinco [G]

05/04/2022, 10:20 PM
Interesting - yes font metrics would affect it since it decides the innerTextField height
c

Colton Idle

05/04/2022, 11:38 PM
"the merged file I'm using" What's a merged file?
s

S.

05/04/2022, 11:46 PM
Sorry, merged fonts. I think i got it from here https://github.com/satbyy/go-noto-universal Can check tomorrow to be sure
👍 2