【android】使用部分模拟器出现兼容问题Error inflating class EditText

在使用部分模拟器(此处我使用的是逍遥模拟器)会出现很奇怪的错误,但在其他手机上或模拟器上没有出现解决方法如下:在style.xml文件中@color/colorPrimary@color/colorP

by
江江
on
2017/07/03
【android】使用部分模拟器出现兼容问题Error inflating class EditText

在使用部分模拟器(此处我使用的是逍遥模拟器)会出现很奇怪的错误,但在其他手机上或模拟器上没有出现

解决方法如下:

在style.xml文件中

<resources>

    <!-- Base application theme. -->
    <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="editTextStyle">@style/EditTextStyle</item>
    </style>
    <style name="EditTextStyle" parent="android:Widget.EditText">
        <item name="android:background">@drawable/abs_edit_text_background</item>
    </style>
</resources>

此处我们自定义editTextStyle风格,自定义EditText背景图片可解决此问题

江江江江于 2026-10-15 08:46:34 修改阅读 3847评论 0点赞 0