The TextInputLayout has a character counter for an EditText defined within it.

The counter will be rendered below the EditText.

Just use the [setCounterEnabled()](<https://developer.android.com/reference/android/support/design/widget/TextInputLayout.html#setCounterEnabled(boolean)>) and [setCounterMaxLength](<https://developer.android.com/reference/android/support/design/widget/TextInputLayout.html#setCounterMaxLength(int)>) methods:

TextInputLayout til = (TextInputLayout) findViewById(R.id.username);
til.setCounterEnabled(true);
til.setCounterMaxLength(15);

or the [app:counterEnabled](<https://developer.android.com/reference/android/support/design/widget/TextInputLayout.html#attr_android.support.design:counterEnabled>) and [app:counterMaxLength](<https://developer.android.com/reference/android/support/design/widget/TextInputLayout.html#attr_android.support.design:counterMaxLength>) attributes in the xml.

<android.support.design.widget.TextInputLayout
    app:counterEnabled="true"
    app:counterMaxLength="15">

    <EditText/>

</android.support.design.widget.TextInputLayout>