任何人都可以解释为什么我在这里收到此错误? 这是res / layout文件夹中的styles.xml
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:buttonStyle">@style/ButtonTheme</item>
</style>
<style name="ButtonTheme" parent="android:Widget.Button">
<item name="android:textColor">@color/Black</item>
<item name="android:background">@color/LightGrey</item>
<item name="android:textSize">23sp</item>
<padding
android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp"
/>
</style>
</resources>
错误似乎发生在ButtonTheme
的填充部分答案 0 :(得分:1)
您应该使用
<item name="android:padding">1dp</item>
而不是
<padding
android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp"
/>
答案 1 :(得分:0)
您错过了命名空间声明。
尝试将xmlns:android="http://schemas.android.com/apk/res/android"
插入<resources>
即
<resources xmlns:android="http://schemas.android.com/apk/res/android">
答案 2 :(得分:0)
你必须使用android前缀命名空间,例如: - android:name =&#34; AppBaseTheme&#34;
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android" >
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style
android:name="AppBaseTheme"
android:parent="Theme.AppCompat.Light" >
答案 3 :(得分:0)
你错过了架构uri,并且填充格式不正确。
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:buttonStyle">@style/ButtonTheme</item>
</style>
<style name="ButtonTheme" parent="android:Widget.Button">
<item name="android:textColor">@color/Black</item>
<item name="android:background">@color/LightGrey</item>
<item name="android:textSize">23sp</item>
<item name="android:paddingLeft">1dp</item>
<item name="android:paddingRight">1dp</item>
<item name="android:paddingTop">1dp</item>
<item name="android:paddingBottom">1dp</item>
</style>
</resources>