material-components / material-components-android

Modular and customizable Material Design UI components for Android
Apache License 2.0
16.1k stars 3.04k forks source link

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

Open StephaneBg opened 4 years ago

StephaneBg commented 4 years ago

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

ldjcmu commented 4 years ago

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 commented 4 years ago

Also:

HintTextAppearance with textAllCaps doesn't work #586

carrymaster commented 4 years ago

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

ezamelczyk commented 4 years ago

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

akhbulatov commented 4 years ago

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

frangulyan commented 4 years ago

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.

vincent-paing commented 4 years ago

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

}
dan-0 commented 4 years ago

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.

VysotskiVadim commented 3 years ago

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

OlehHaidaienko commented 3 years ago

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

neild001 commented 3 years ago

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

kroegerama commented 3 years ago

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

mykola-dev commented 3 years ago

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

sstanislavsky commented 2 years ago

textAllCaps for hint does not work still Any suggestions?

vaidadry commented 2 years ago

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

ipekbirinci commented 1 month ago

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.