material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[TextInputEditText] Several issues with typefaces in TextInputEditText (e.g.,Typeface is not applied with textPassword inputType)

Open StephaneBg opened this issue 6 years ago • 16 comments

Description: Typeface is not applied with textPassword inputType.

Expected behavior: When android:inputType="text|textPassword|textNoSuggestions" (incorrect behaviour) Screenshot_1568119309

When android:inputType="text|textNoSuggestions" (expected behaviour) Screenshot_1568119497

Source code:

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/passwordInputAlphanumeric"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/margin_padding_size_medium"
            android:theme="@style/Widget.App.TextInputLayout"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            >

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/passwordAlphanumeric"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/login_hint_password"
                android:imeOptions="actionDone"
                android:inputType="text|textPassword|textNoSuggestions"
                android:maxLines="1"
                tools:ignore="Autofill,LabelFor"
                tools:text="11223344"
                />
        </com.google.android.material.textfield.TextInputLayout>


<style name="Base.TextAppearance" parent="@style/TextAppearance.AppCompat">
    <item name="android:fontFamily">@font/ubuntu_regular</item>
    <item name="fontFamily">@font/ubuntu_regular</item>
</style>

Android API version: All

Material Library version: 1.0.0

Device: Emulators

StephaneBg avatar Sep 10 '19 12:09 StephaneBg

Also related: When I try to set a font family in HintTextAppearance. It doesnt work. Is there any reason?

 <style name="hintStyle" parent="TextAppearance.Design.Hint">
        <item name="android:fontFamily">@font/xyz</item>
        <item name="android:textColor">@android:color/holo_red_dark</item>
        <item name="android:textSize">12sp</item>
    </style>

** Material Library version:** Material Android Library version 1.1.0-alpha10

ldjcmu avatar Oct 01 '19 21:10 ldjcmu

Also:

HintTextAppearance with textAllCaps doesn't work #586

ldjcmu avatar Oct 01 '19 22:10 ldjcmu

Also related: When I try to set a font family in HintTextAppearance. It doesnt work. Is there any reason?

 <style name="hintStyle" parent="TextAppearance.Design.Hint">
        <item name="android:fontFamily">@font/xyz</item>
        <item name="android:textColor">@android:color/holo_red_dark</item>
        <item name="android:textSize">12sp</item>
    </style>

** Material Library version:** Material Android Library version 1.1.0-alpha10

also not working in 1.1.0-beta02

carrymaster avatar Dec 06 '19 02:12 carrymaster

Jesus christ this library is a steaming pile of shit. Nothing is working.

ezamelczyk avatar Feb 14 '20 11:02 ezamelczyk

The same bug. Any news when this will be fixed?

akhbulatov avatar Mar 09 '20 01:03 akhbulatov

Seems like the fontFamily of the inner TextInputEditText is also applied to the hint, even when the outer TextInputLayout sets it to something else using hintTextAppearance.

frangulyan avatar Mar 29 '20 01:03 frangulyan

If you write a custom typeface override to reuse all over the project programatically, it doesn't render correctly

class FontOverrideEditText @JvmOverloads constructor(
  context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : TextInputEditText(context, attrs, defStyleAttr) {

  init {
    typeface = ResourcesCompat.getFont(context, R.font.your_font)
  }

}

vincent-paing avatar Jun 17 '20 12:06 vincent-paing

Is an issue on (current latest) 1.3.0-alpha01 still.

At this time, we can't use TextInputLayout because of the issue pointed out in #586 specifically. Use requires a series of focus, error, and text change listeners to determine the appearance of the TextInputLayout hint text.

dan-0 avatar Jun 29 '20 14:06 dan-0

Looks like hintTextAppearance doesn't work because it's always overridden by the inner edit text text style. Is it expected behavior, or it's something that will be fixed? image

VysotskiVadim avatar Aug 05 '20 13:08 VysotskiVadim

A temporary workaround can be setting hint text appearance after the view layout textInputFieldView.doOnLayout { textInputFieldView.setHintTextAppearance(R.style.TextInputFieldHintTextAppearance) }

OlehHaidaienko avatar Nov 30 '20 08:11 OlehHaidaienko

Seeing the same problem would be great to see this fixed.

neild001 avatar Apr 27 '21 11:04 neild001

The bug still exists in 1.4.0-alpha02. ~1.5 years since the first report. Sometimes this library seems like it's been abandoned by its creators. 🙁

@leticiarossi and @ymarian you seem to be quite active on this component. Any news about this bug? 🙂

kroegerama avatar May 09 '21 14:05 kroegerama

the app compat widgets the material components widgets should we wait for 3rd iteration of UI elements library which finally would work?

mykola-dev avatar May 26 '21 14:05 mykola-dev

textAllCaps for hint does not work still Any suggestions?

sstanislavsky avatar Jul 28 '21 17:07 sstanislavsky

Typeface is not applied with textPassword inputType -> still appears on 1.5.0

vaidadry avatar Apr 08 '22 08:04 vaidadry

I have similar problem even now. I want to make hint's font poppins and edittext's poppins_semibold but two of them became poppins_semibold.

ipekbirinci avatar May 20 '24 06:05 ipekbirinci