I am trying to make something on these lines:
I am able to show the hint using android:hint="Email Address"
but unable to show the helper text - This will be your email username
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/et_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="15"
android:hint="Username"
app:et_helper="Username is preferably your registered email"/>
</android.support.design.widget.TextInputLayout>`
What I am getting is only and no Username is preferably your registered email below edittext:
Output:
Any pointers appreciated. Thank you.
The best way is to use
TextInputLayout
. Google introduced it in new design library. In order to use the TextInputLayout you have to add the following to your build.gradle dependencies:Then use it in your xml files:
You can set your text by setting error true. Altough it is for showing errors but it is suitable for your use. You can change color and typeface if you want.
So what you want is this:
Helper Text
You can achieve this by using this library:
https://github.com/rengwuxian/MaterialEditText
You can set the "helper text" attribute to show the text below the line and the "hint" to show the text above the line. Below is the sample layout for the attached picture
The Helper Text is not provided by TextInputLayout. However, the article below has a working example of it. It uses a class that extends from TextInputLayout by adding HelperText as another indicator to the class, working along side with the ErrorText.
https://medium.com/@elye.project/material-login-with-helper-text-232472400c15#.vm28p662v
I had similar question asked here. If you want to keep two EditText views together closed vertically in LinearLayout, I think there is no way. One way, I think, is you can set the android:gravity of top EditText to 'bottom' and 'top' to the lower EditText. But in RelativeLayout, This should be easy.
TextInputLayout can be used if you want to show the hint text (on top of EdiText) even while user typing it. Usually with setting hint to EditText would not work this way. Hint text would disappear after the view is focussed by touching it.
With Design Support Library 28 , an inbuilt helper Text feature is added in TextInputLayout.
Now enable error using xml or programmatically
Also , hint and error can together be used now!!!
Example
TextInputLayout | Android Developers
EDIT Don't forget to enable error and helperText via xml or programatically.