简体   繁体   中英

How to change the border width of OutlinedTextField?

I tried using the border modifier, but this sets the border over the label as well and I don't want this behaviour. I just want to make the border thicker and not the default of 1dp.

This will not be possible (at least, easily). You see, the OutlinedTextField (and pretty much all the TextField s) is very intricately connected to internal dependencies in Compose. Just look at its source code. You will find it connects to a TextFieldImp which contains many dependencies which cannot be lifted out as usable stuff since they are internal . So, the only option left with you is actually creating your own Composable. This is not something very hard, but may require good knowledge of the Layout Composable, and how things work in Compose, like measurement and positioning. Anyway, I don't think it is worth the effort to create such a thing when you can just go with the defaults. If you still want to go for a thicker border, my bet recommendation would be to just use a placeholder instead of label , and then apply the border Modifier.

Other than this, the requested implementation is not even practical to implement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM