2016-05-05 19 views
1

ich dies unter XML-Code verwenden:Wie nach dem Fokus verloren Hinweis Farbe für TextInputLayout einstellen

  <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> 

Szenario:
Schritt 1: Edittext1 ist blank- Hinttextcolor = Schwarz.
Schritt 2: Edittext1 Wert eingegeben Hinttext = Orange.
Schritt 3: Lostfocus von Edittext1 zu Edittext2, Edittext1 hinttext = Orange. Benutzte AppcompactEdittext und TextInputLayout.

Bitte helfen Sie mir.

+0

post your style '@ style/TextLabel' – Bharatesh

Antwort

-1

Verwendung von XML:

android:textColorHint="#FFFFFF" 

mit Java:

editText.setHintTextColor(Color.rgb(255,255,255)); 
+1

* TextInputLayout !! * NICHT EditText – avisper

0

Bewerben setOnFocusChangeListener(this) zum AppCompatEditText
dann onfocuschange:

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

} 
+0

Bitte beachten Sie das oben aufgeführte Szenario –

0

du wieder ..

in der übergeordneten Layout Child hinzufügen ..

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

, wo Sie

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

Satz dieser Art in Ihrem 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> 
1

android:textColorHint="@color/your_color" 
Put verwenden

innerhalb

Verwandte Themen