我正在用android.support.v7.widget.Toolbar小部件编写自己的工具栏,我想尽可能多地放入res文件夹中的styles.xml.
/res/layout/$example.xml中文件的一部分
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toolbar_show_addresses_simple"
app:style="@style/toolbar_dark" >
Run Code Online (Sandbox Code Playgroud)
我的"toolbar_dark"在/res/values/styles.xml中定义如下
<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="app:theme">@style/ThemeOverlay.AppCompat.Dark</item>
<item name="app:popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
<item name="app:contentInsetStart">0dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
编译时
Output:
Error: No resource found that matches the given name: attr 'app:contentInsetStart'.
Error: No resource found that matches the given name: attr 'app:popupTheme'.
Error: No resource found that matches the given name: attr 'app:theme'.
Run Code Online (Sandbox Code Playgroud)
如果我直接在$ example.xml中使用app:*值,一切正常.因此,如何在res文件夹中的文件中使用我的app命名空间?