Android XML中的错误-无界前缀
有人能解释我为什么会在这里出错吗? 这是res/layout文件夹中的my styles.xmlAndroid XML中的错误-无界前缀,android,Android,有人能解释我为什么会在这里出错吗? 这是res/layout文件夹中的my 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. --> <
<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>
@款式/钮扣
@颜色/黑色
@颜色/浅灰色
23便士
错误似乎发生在ButtonTheme中的padding部分,您错过了名称空间声明。 尝试插入
xmlns:android=”http://schemas.android.com/apk/res/android“
转换为
i、 e
您必须使用android前缀命名空间,例如:-android:name=“AppBaseTheme”
您应该使用
<item name="android:padding">1dp</item>
1dp
而不是
<padding
android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp"
/>
缺少架构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>
@款式/钮扣
@颜色/黑色
@颜色/浅灰色
23便士
1dp
1dp
1dp
1dp
android没有名称空间。你可以使用1dp
我认为填充行有问题,它不是这样定义填充的方法。没有必要在style.xml文件中定义填充,你是否检查过答案,在这里发布之前在哪里工作?
<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>