【问题标题】:Connot find declaration to go to找不到要前往的声明
【发布时间】:2017-06-03 14:02:23
【问题描述】:

已解决,以下代码正常,外部库导致此问题。

我的style 中有一个带有自定义主题的NavigationView

    <android.support.design.widget.NavigationView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:itemTextColor="@color/nav_state_list"
        app:menu="@menu/drawer_menu"
        app:headerLayout="@layout/nav_header"
        app:itemTextAppearance="@style/NavDrawerTextStyle"
android:theme="@style/navTheMe"

    </android.support.design.widget.NavigationView>

风格(navTheMe)

<style name="navTheMe" parent="AppThemee">
    <item name="android:textSize">12sp</item>
    <item name="android:textStyle">bold</item>
    <item name="listPreferredItemPaddingRight">90dip</item>
</style>

但它找不到我的主题,它说:

找不到要前往的声明

而且我的主题不会被应用

已经好几个小时了,我无法弄清楚发生了什么

【问题讨论】:

    标签: android xml styles themes navigationview


    【解决方案1】:

    您应该从 style.xml

    中的 parent 属性中删除第二个 e
    <style name="navTheMe" parent="AppTheme">
        <item name="android:textSize">12sp</item>
        <item name="android:textStyle">bold</item>
        <item name="listPreferredItemPaddingRight">90dip</item>
    </style>
    

    此外,要将这个新主题应用到您的 NavigationView 布局,您应该使用 app:theme=""@style/navTheMe" 属性而不是 android:theme="@style/navTheMe

    <android.support.design.widget.NavigationView 
        xmlns:android="http://schemas.android.com/apk/res/android" 
        xmlns:app="http://schemas.android.com/apk/res-auto" 
        ...
        app:theme="@style/navTheMe">
            ...
    </android.support.design.widget.NavigationView>
    

    【讨论】:

    • 感谢您的回复,Appthemee 是我的主题名称.. 我已将 android 前缀更改为 app,它现在正在找到我的主题,但仍然没有应用它
    • 你能发布 Appthemee 主题吗?谢谢
    • 我刚刚发现了问题,最近我在我的项目中添加了一个库,我才意识到,这个库导致了这个问题,我不知道究竟是为什么,所以我把它从我的项目,现在我正在使用另一个具有相同功能的库,感谢您的帮助 BTW
    猜你喜欢
    • 1970-01-01
    • 2020-12-05
    • 1970-01-01
    • 2018-05-25
    • 1970-01-01
    • 2021-07-17
    • 2022-12-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多