为 App 设置自定义主题时 TextInputLayout 崩溃
TextInputLayout Crashing when setting Custom Theme for App
以下代码与大纲输入框完美配合。
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/notes"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/text_notes"
app:boxBackgroundColor="@color/colorWhite">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_notes"
android:fontFamily="sans-serif-black"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
我要在整个应用程序中设置自定义字体。通过以下代码设置后,它正在崩溃。以下样式用于 App 主题。
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textViewStyle">@style/SansSerifTextViewStyle</item>// Custom font style
<item name="buttonStyle">@style/SanSerifButtonStyle</item> // Custom font style
</style>
当我删除下面的行时,应用程序不会崩溃。但是轮廓框 UI 不会出现。尝试通过 Java 代码进行设置,但不起作用。
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
Material 组件,如 com.google.android.material.textfield.TextInputLayout
(注意包名称的 .material.
部分),要求您使用 Material 主题。
此页面列出了要使用的适当主题:
您必须从此更改您应用的主题
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
例如这个
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
以下代码与大纲输入框完美配合。
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/notes"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/text_notes"
app:boxBackgroundColor="@color/colorWhite">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_notes"
android:fontFamily="sans-serif-black"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
我要在整个应用程序中设置自定义字体。通过以下代码设置后,它正在崩溃。以下样式用于 App 主题。
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textViewStyle">@style/SansSerifTextViewStyle</item>// Custom font style
<item name="buttonStyle">@style/SanSerifButtonStyle</item> // Custom font style
</style>
当我删除下面的行时,应用程序不会崩溃。但是轮廓框 UI 不会出现。尝试通过 Java 代码进行设置,但不起作用。
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
Material 组件,如 com.google.android.material.textfield.TextInputLayout
(注意包名称的 .material.
部分),要求您使用 Material 主题。
此页面列出了要使用的适当主题:
您必须从此更改您应用的主题
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
例如这个
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">