While using this style from material styles, It doesn't matter where I provide the TextAppearance in my AppTheme or extend that style itself and provide TextAppearance
The app crashes with the following error:
E/AndroidRuntime: Caused by: java.lang.IllegalArgumentException: This component requires that you specify a valid TextAppearance attribute. Update your app theme to inherit from Theme.MaterialComponents (or a descendant). at com.google.android.material.internal.ThemeEnforcement.checkTextAppearance(ThemeEnforcement.java:185) at com.google.android.material.internal.ThemeEnforcement.obtainTintedStyledAttributes(ThemeEnforcement.java:116) at com.google.android.material.textfield.TextInputLayout.(TextInputLayout.java:474) at com.google.android.material.textfield.TextInputLayout.(TextInputLayout.java:433)
The XML component looks like below
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/txtcountry"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_10sdp"
android:hint="@string/select_country"
android:textColorHint="@color/dark_blue"
app:boxCornerRadiusBottomEnd="@dimen/_10sdp"
app:boxCornerRadiusBottomStart="@dimen/_10sdp"
app:boxCornerRadiusTopEnd="@dimen/_10sdp"
app:boxCornerRadiusTopStart="@dimen/_10sdp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:startIconDrawable="@drawable/ic_baseline_location_city_24">
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="@+id/spinner_country"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:inputType="none" />
</com.google.android.material.textfield.TextInputLayout>
You must check the parent theme (in themes.xml file) and use a style that matches that theme. In your case, something like:
For instance, if MyApplication has the following MaterialComponents theme:
Then I have to use style matching to MaterialComponents:
If I try to use Material3 style
I would have a similar error.