为什么它说即使它存在"No resource found that matches"也有错误?



错误消息

error: Error: No resource found that matches the given name (at 'style' with value '@style/rightBehindMenuScroll').

layout/activity_behind_right_simple.xml

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/rightBehindMenuScroll" >
    <LinearLayout style="@style/behindMenuScrollContent"
        android:paddingTop="25dp" >
        <TextView
            style="@style/behindMenuItemTitle"
            android:text="Right" />
        <TextView
            style="@style/behindMenuItemLabel"
            android:text="Item0" />
        <TextView
            style="@style/behindMenuItemLabel"
            android:text="Item1" />
        <Button
            android:id="@+id/behind_btn"
            style="@style/behindMenuItemLabel"
            android:text="BUTTON" />
    </LinearLayout>
</ScrollView>

values/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="android:Theme.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">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

    <style name="leftBehindMenuScroll">
        <item name="android:layout_width">240dp</item>
        <item name="android:layout_height">fill_parent</item>
        <item name="android:background">@drawable/leftbg</item>
    </style>
    <style name="rightBehindMenuScroll">
        <item name="android:layout_width">200dp</item>
        <item name="android:layout_height">fill_parent</item>
        <item name="android:background">@drawable/rightbg</item>
    </style>
    <style name="behindMenuScrollContent">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">fill_parent</item>
        <item name="android:orientation">vertical</item>
        <item name="android:padding">8dp</item>
    </style>
    <style name="behindMenuItemTitle">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_marginLeft">8dp</item>
        <item name="android:layout_marginBottom">8dp</item>
        <item name="android:textSize">22sp</item>
        <item name="android:textColor">#FFFFFF</item>
    </style>
    <style name="behindMenuItemLabel">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_marginLeft">8dp</item>
        <item name="android:layout_marginBottom">8dp</item>
        <item name="android:textSize">18sp</item>
        <item name="android:textColor">#FFFFFF</item>
    </style>
</resources>

这是因为您使用的是styles.xml而不是style.xml。

请尝试按以下方式更改引用。。。

 <TextView
            style="@styles/behindMenuItemTitle"
            android:text="Right" />

以与styles.xml文件的所有其他引用相同的方式。。。

相关内容

最新更新