You can use the TextInputLayout
to display error messages according to the material design guidelines using the [setError](<https://developer.android.com/reference/android/support/design/widget/TextInputLayout.html#setError(java.lang.CharSequence)>)
and [setErrorEnabled](<https://developer.android.com/reference/android/support/design/widget/TextInputLayout.html#setErrorEnabled(boolean)>)
methods.
In order to show the error below the EditText use:
TextInputLayout til = (TextInputLayout) findViewById(R.id.username);
til.setErrorEnabled(true);
til.setError("You need to enter a name");
To enable error in the TextInputLayout
you can eithr use app:errorEnabled="true"
in xml or til.setErrorEnabled(true);
as shown above.
You will obtain: