app namespace not found in styles.xml in res folder

后端 未结 2 1089
醉话见心
醉话见心 2020-12-08 19:03

I\'m writing my own toolbar with an android.support.v7.widget.Toolbar widget and I want to put as much as possible into a styles.xml in my res folder.

Part of a file

相关标签:
2条回答
  • 2020-12-08 19:36

    Use Android replace app in style file:

    <style name="toolbar_dark">
       <item name="android:layout_width">match_parent</item>
       <item name="android:layout_height">wrap_content</item>
       <item name="android:background">@color/myPrimary</item>
       <item name="android:theme">@style/ThemeOverlay.AppCompat.Dark</item>
       <item name="android:popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
       <item name="android:contentInsetStart">0dp</item>
    </style>
    
    0 讨论(0)
  • 2020-12-08 19:45

    You can't use an app namespace in your style file, and you should refer to style attribute wihtout app namespace in your layout.

    You can do somenthing like this:

    <android.support.v7.widget.Toolbar    
           xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/toolbar_show_addresses_simple"
            style="@style/toolbar_dark" >
    

    Style:

    <style name="toolbar_dark" parent="Widget.AppCompat.Toolbar">
        <item name="android:background">@color/green</item>
        <item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
        <item name="theme">@style/ThemeOverlay.AppCompat.Dark</item>
    </style>
    
    0 讨论(0)
提交回复
热议问题