Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override styles for EditText in Android

I need to override styles for two EditText instances. I have two issues regarding this:

1) One EditText is for entering a password but with the same typeface. If I delete password=true it works. 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 hints. And I need to set the color of these hints; is it possible? I didn't find something like this: android:hintColor...

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

I tried two variants for password type:

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

Both change typeface to default automaticaly, even in the "UI Constructor".

like image 738
GeX Avatar asked Jun 25 '12 08:06

GeX


1 Answers

For your second problem, this can be helpful(under the EditText tag):

        android:textColorHint="#3b64a8"

In your Activity:

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

here "passwordText" is the EditText for password.

like image 122
Yogesh Somani Avatar answered Oct 15 '22 09:10

Yogesh Somani