Igor Karun
Igor Karun

Reputation: 629

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:

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

Upvotes: 5

Views: 5623

Answers (2)

K_Anas
K_Anas

Reputation: 31466

This should work, Try it

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

Upvotes: 3

Yogesh Somani
Yogesh Somani

Reputation: 2624

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.

Upvotes: 6

Related Questions