Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Password hint font is different than other edittext fields

EditText password = (EditText) view.findViewById(R.id.etPassword);

    if (Build.VERSION.SDK_INT != android.os.Build.VERSION_CODES.KITKAT) {
        Typeface typeface = TypefaceUtil.overrideFont(getContext(), "SERIF", "fonts/calibri.ttf");
        password.setTypeface(typeface);
    }

And this is the XML layout for the TextInputLayout

<android.support.design.widget.TextInputLayout
    android:id="@+id/inpPassword"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="@dimen/button_margin_small">

    <android.support.design.widget.EditText
        android:id="@+id/etPassword"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif"
        android:hint="@string/set_pass"
        android:inputType="textPassword"
        android:maxLength="@integer/pass_max"
        android:maxLines="1"
        android:password="true"
        android:singleLine="true" />
</android.support.design.widget.TextInputLayout>

I am trying to use this code but my password hint font style is different than which I had set.

like image 494
Ruchita Sharma Avatar asked Aug 17 '17 13:08

Ruchita Sharma


1 Answers

Try this

<Edittext
            android:id="@+id/edtPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Password"
            android:inputType="text"
            android:textSize="14sp" />

Set android:inputType="text" in your edittext xml.

Set edtPassword.setTransformationMethod(new PasswordTransformationMethod()); in java file.

Works for me in custom font for edittext.

like image 193
Velayutham M Avatar answered Oct 03 '22 18:10

Velayutham M