Skip to content

Commit

Permalink
[TextInputLayout] Added class documentation to use TextInputLayout's …
Browse files Browse the repository at this point in the history
…context to construct the child TextInputEditText.

We already had class documentation that explains that TextInputEditText should be instantiated with the parent TextInputLayout's context for proper theming, but this  information is important enough to the basic usage of TextInputLayout and TextInputEditText that it's best to have it the class documentation, as well.

Added the guidance in both TextInputLayout and TextInputEditText because it's relevant to both classes.

PiperOrigin-RevId: 432244388
  • Loading branch information
afohrman committed Mar 4, 2022
1 parent 2555c9b commit 1085583
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Expand Up @@ -44,6 +44,11 @@
*
* <p>Using this class allows us to display a hint in the IME when in 'extract' mode and provides
* accessibility support for {@link com.google.android.material.textfield.TextInputLayout}.
*
* <p><strong>Note:</strong> If you programmatically construct a {@link TextInputEditText} as a
* child of a {@link TextInputLayout}, you should use {@link TextInputLayout}'s `context` to
* create the view. This will allow {@link TextInputLayout} to pass along the appropriate styling
* to the {@link TextInputEditText}.
*/
public class TextInputEditText extends AppCompatEditText {

Expand Down
Expand Up @@ -147,7 +147,7 @@
* <p>The {@link TextInputEditText} class is provided to be used as the input text child of this
* layout. Using TextInputEditText instead of an EditText provides accessibility support for the
* text field and allows TextInputLayout greater control over the visual aspects of the text field.
* An example usage is as so:
* This is an example usage:
*
* <pre>
* &lt;com.google.android.material.textfield.TextInputLayout
Expand All @@ -169,6 +169,11 @@
* TextInputLayout#setHint(CharSequence)} and {@link TextInputLayout#getHint()} on TextInputLayout,
* instead of on EditText.
*
* If you construct the {@link TextInputEditText} child of a {@link TextInputLayout}
* programmatically, you should use {@link TextInputLayout}'s `context` to create the view. This
* will allow {@link TextInputLayout} to pass along the appropriate styling to the
* {@link TextInputEditText}.
*
* <p>If the {@link EditText} child is not a {@link TextInputEditText}, make sure to set the {@link
* EditText}'s {@code android:background} to {@code null} when using an outlined or filled text
* field. This allows {@link TextInputLayout} to set the {@link EditText}'s background to an
Expand Down

0 comments on commit 1085583

Please sign in to comment.