I want to make a EditTextLayout
, but I want a different text for label and hint.
For example : The label's text is "Phone Number", and the hint text is "+6281342134".
Is it possible?
My code is:
<android.support.design.widget.TextInputLayout
android:id="@+id/phone_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="+6281342134"
android:inputType="phone" />
</android.support.design.widget.TextInputLayout>
I took a similar approach to Rehan
<android.support.design.widget.TextInputEditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
inputLayout.setHint("We did it!");
} else {
inputLayout.setHint("Testing 123");
}
}
});
The animation was good enough for me without disabling the animation: