2

I am using this below xml code:

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/TextLabel">

                <android.support.v7.widget.AppCompatEditText
                    android:id="@+id/edtAddress1Current"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/border_button"
                    android:hint="My Hint" 
                    android:singleLine="true"
                    android:textColor="@color/blue"
                                                     />
            </android.support.design.widget.TextInputLayout> 

Scenario:
Step 1: Edittext1 is blank- Hinttextcolor = Black.
Step 2: Edittext1 value entered Hinttext = Orange.
Step 3: Lostfocus from Edittext1 to Edittext2, Edittext1 hinttext=Orange. Used AppcompactEdittext and TextInputLayout.

Please help me out.

Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98
Digvijay Machale
  • 601
  • 7
  • 12

4 Answers4

2

Put

android:textColorHint="@color/your_color"

inside TextInputLayout

Rob
  • 26,989
  • 16
  • 82
  • 98
Priyanka
  • 381
  • 1
  • 6
  • 8
0

Apply setOnFocusChangeListener(this) to the AppCompatEditText
then onfocuschange:

@Override 
public void onFocusChange(View v, boolean hasFocus) {
    if(v.getId() == R.id.edtAddress1Current && !hasfocus){
         v.setHintTextColor("#FCFCFC")
    }

}
Ibrahim Gharyali
  • 544
  • 3
  • 22
0

You can Try this..

add in the Parent layout Child..

   xmlns:app="http://schemas.android.com/apk/res-auto"

Take where you are using

 <android.support.design.widget.TextInputLayout       
  android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:textAppearance="?android:attr/textAppearanceMedium"
  app:errorTextAppearance="@style/TextLabelInput"
 />

set this style in your styles.xml

<style name="TextLabelInput" parent="TextAppearance.AppCompat">
    <!-- Hint color and label color in FALSE state -->
    <item name="android:textColorHint">@color/solid_red</item>
    <item name="android:textSize">16sp</item>
    <item name="android:textStyle">bold</item>
    <item name="android:textColor">@color/solid_red</item>

</style>
Arjun saini
  • 4,223
  • 3
  • 23
  • 51
-1

Using XML:

android:textColorHint="#FFFFFF"

Using Java:

editText.setHintTextColor( Color.rgb(255,255,255));
Pang
  • 9,564
  • 146
  • 81
  • 122
Nouman Shah
  • 534
  • 1
  • 9
  • 22