Search code examples
androidandroid-edittextandroid-typeface

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.


Solution

  • addding to this, It works when the iandroid:inputType=" textPassword" is removed and adding app:passwordToggleEnabled="true"

    <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"
                app:passwordToggleEnabled="true">
    
                <EditText
                    android:id="@+id/etPassword"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/set_pass"
                    android:maxLength="@integer/pass_max"
                    android:maxLines="1"
                    android:singleLine="true" />
            </android.support.design.widget.TextInputLayout>
    
    
    
    EditText password = (EditText) view.findViewById(R.id.etPassword);
        password.setTypeface(Typeface.DEFAULT);
        password.setTransformationMethod(new PasswordTransformationMethod());