Fixed
Status Update
Comments
so...@google.com <so...@google.com> #2
Before I saw this ticket I created this change aosp/1292294 which basically improves the documentation and the sample.
Let me know what you think. But if you still prefer we remove the default from the modifier, I am ok with that too.
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 6a6faa78e82977ba346a85d5f8d543645e2ba3e7
Author: Anastasia Soboleva <soboleva@google.com>
Date: Wed Apr 22 19:48:41 2020
TextField fills max width
Fixes: 154638552
Test: new tests and checked text field demos
Relnote: "TextField update - in horizontal dimension it will occupy all available space granted to it"
Change-Id: Ib08dfc0363c5a3521f68c750ba6dc490a25081d3
M ui/ui-foundation/api/0.1.0-dev10.txt
M ui/ui-foundation/api/current.txt
M ui/ui-foundation/api/public_plus_experimental_0.1.0-dev10.txt
M ui/ui-foundation/api/public_plus_experimental_current.txt
M ui/ui-foundation/api/restricted_0.1.0-dev10.txt
M ui/ui-foundation/api/restricted_current.txt
M ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldTest.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/TextField.kt
https://android-review.googlesource.com/1292294
Branch: androidx-master-dev
commit 6a6faa78e82977ba346a85d5f8d543645e2ba3e7
Author: Anastasia Soboleva <soboleva@google.com>
Date: Wed Apr 22 19:48:41 2020
TextField fills max width
Fixes: 154638552
Test: new tests and checked text field demos
Relnote: "TextField update - in horizontal dimension it will occupy all available space granted to it"
Change-Id: Ib08dfc0363c5a3521f68c750ba6dc490a25081d3
M ui/ui-foundation/api/0.1.0-dev10.txt
M ui/ui-foundation/api/current.txt
M ui/ui-foundation/api/public_plus_experimental_0.1.0-dev10.txt
M ui/ui-foundation/api/public_plus_experimental_current.txt
M ui/ui-foundation/api/restricted_0.1.0-dev10.txt
M ui/ui-foundation/api/restricted_current.txt
M ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldTest.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/TextField.kt
Description
val state = state { TextFieldValue() }
TextField(
value = state.value,
onValueChange = { state.value = it }
)
I copy it to my app and there is nothing displayed and I can't understand why.
It happened because the default text is "", it wraps content and the size of the TextField is 0x0 as a result.
It is solved by the material implementation FilledTextField as it provides the default min size, but here we have to solve it differently.
And it is not the first component which is 0x0 by default and we want to force people to think about its size via api. What we did for similar components Spacer and Canvas(from ui-foundation) - we removed the default value for the modifier parameter. In the documentation for Canvas we have "@param modifier mandatory modifier to specify size strategy for this composable".
I propose the same fix for TextField: move modifier to be a first param and remove the default value. We should also update a sample to provide some size like Modifier.size(48.dp)
wdyf?