2016-04-05 12 views
0

Ich habe dieses TextInputLayout und EditText und mein Texthinweis ist schwarze Farbe und ich möchte es ändern.Android TextInput Hinweis Textfarbe

Durch die Art und Weise, wenn der Hinweis auf seine Farbe wird weiß

<android.support.design.widget.TextInputLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout"> 

      <EditText 
       android:id="@+id/password" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:hint="@string/prompt_password" 
       android:imeActionId="@+id/login" 
       android:imeActionLabel="@string/action_sign_in_short" 
       android:imeOptions="actionUnspecified" 
       android:inputType="textPassword" 
       android:maxLines="1" 
       android:singleLine="true" 
       android:textColor="@android:color/white" 
       android:textColorHint="@android:color/white" /> 

     </android.support.design.widget.TextInputLayout> 

Styles

<style name="TextAppearance.App.TextInputLayout" parent="@android:style/TextAppearance"> 
    <item name="android:textColor">@android:color/white</item> 
    <item name="android:textColorHint">@android:color/white</item> 
    <item name="colorPrimary">@android:color/white</item> 
    <item name="colorAccent">@android:color/white</item> 
</style> 

enter image description here

+0

Haben Sie es gelöst? – josedlujan

Antwort

0

Sie sollten mehr Attribute wie folgt definieren:

<style name="TextAppearance.App.TextInputLayout" parent="TextAppearance.AppCompat"> 
    <item name="android:textColor">@android:color/white</item> 
    <item name="android:textColorHint">@android:color/white</item> 
    <item name="colorPrimary">@android:color/white</item> 
    <item name="colorAccent">@android:color/white</item> 

    <item name="colorControlNormal">@color/someColor</item> 
    <item name="colorControlActivated">@color/someColor</item> 
    <item name="colorControlHighlight">@color/someColor</item> 

</style> 
+0

Es funktioniert nicht. –

+0

@KirillZotov haben Sie diese drei Attribute definiert? ' @ color/someColor @ color/someColor @ color/someColor' –

+0

auch sicherstellen, dass Eltern von Das Thema ist 'TextAppearance.AppCompat'. Ich habe meine Antwort aktualisiert. Bitte überprüfe es nocheinmal. –

1
  1. Verwenden Sie dies, um die Hinweisfarbe zu ändern. -

    editText.setHintTextColor (getResources(). GetColor (R.color.white));

  2. einfach dies für die EditText in Ihrem Layout hinzufügen:

    android: textColorHint = "# FFFFFF"

  3. Und wenn Sie so wollen, dann können Sie das tun,

    editText.addTextChangedListener (neu TextWatcher() { public void OnTextChanged (CharSequence arg0, int arg1, arg2 int, int arg3) {// etwas tun }

    public void beforeTextChanged (CharSequence arg0, int arg1, arg2 int, int arg3) {// do something}

    public void afterTextChanged (Editierbare arg0) { if (arg0.toString(). Length() < = 0)
    tv.setHintTextColor (getResources(). GetColor (R.color.white)); } });