Adding Character Counting
suggest changeThe TextInputLayout has a character counter for an EditText defined within it.
The counter will be rendered below the EditText.
Just use the setCounterEnabled()
and setCounterMaxLength
methods:
TextInputLayout til = (TextInputLayout) findViewById(R.id.username); til.setCounterEnabled(true); til.setCounterMaxLength(15);
or the app:counterEnabled
and app:counterMaxLength
attributes in the xml.
<android.support.design.widget.TextInputLayout app:counterEnabled="true" app:counterMaxLength="15"> <EditText/> </android.support.design.widget.TextInputLayout>
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents