Override styles for EditText in Android

I need to override the styles for two instances of EditText. I have two questions:

1) One EditText is designed to enter a password, but with the same font. If I remove the password = true, it will work. By default, typeface = sans.

<style name="customEdit" parent="@android:style/Widget.EditText"> <item name="android:password">true</item> <item name="android:typeface">serif</item> //doesn work. </style> 

2) Both fields have prompts. And I need to set the color of these hints; Is it possible? I did not find something like this: android: hintColor ...

 <item name="android:textColor">#acacac</item> //works for text only. 

I tried two options for the password type:

  • Android: inputType = "textPassword"
  • Android: password = true

Both change the default font automatically, even in the "UI Designer".

+4
source share
2 answers

For your second problem, this may be useful (in the EditText tag):

  android:textColorHint="#3b64a8" 

In your activity:

  passwordText.setTypeface(Typeface.SERIF); passwordText.setTransformationMethod(new PasswordTransformationMethod()); 

here "passwordText" is the EditText for the password.

+5
source

This should work, try

 <style name="customEdit" parent="@android:style/Widget.EditText"> <item name="android:inputType">textPassword</item> <item name="android:password">true</item> <item name="android:typeface">serif</item> <item name="android:textColorHint=">#F28EC1</item> <item name="android:textSize">20sp</item> <item name="android:textStyle">bold</item> </style> 
+1
source

All Articles