Java 这个Android可绘制的背景资源是什么?

Java 这个Android可绘制的背景资源是什么?,java,android,Java,Android,我刚刚开始学习安卓系统,目前正在谷歌安卓开发者网站上浏览教程,到目前为止还没有给我留下深刻印象,因为还有很多事情无法解释 在教程“设置动作栏样式”中,它有以下XML样式资源: <?xml version="1.0" encoding="utf-8"?> <resources> <!-- the theme applied to the application or activity --> <style name="CustomActio

我刚刚开始学习安卓系统,目前正在谷歌安卓开发者网站上浏览教程,到目前为止还没有给我留下深刻印象,因为还有很多事情无法解释

在教程“设置动作栏样式”中,它有以下XML样式资源:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- the theme applied to the application or activity -->
    <style name="CustomActionBarTheme"
           parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MyActionBar</item>

        <!-- Support library compatibility -->
        <item name="actionBarStyle">@style/MyActionBar</item>
    </style>

    <!-- ActionBar styles -->
    <style name="MyActionBar"
           parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@drawable/actionbar_background</item>

        <!-- Support library compatibility -->
        <item name="background">@drawable/actionbar_background</item>
    </style>
</resources>

@样式/MyActionBar
@样式/MyActionBar
@可绘制/操作栏\u背景
@可绘制/操作栏\u背景
(Android 2.1+支持)

它没有提到@drawable/actionbar_背景是什么?因为它是“可绘制的”,所以这是图像吗?我不明白为什么会这样,因为这是为了给动作条的背景上色

任何帮助都将不胜感激

线路

<item name="background">@drawable/actionbar_background</item>
@drawable/actionbar\u背景
翻译成英语就像

在此样式中添加一个表示名为“背景”的属性的项。 作为此属性的值,将“drawable”类型的资源设置为 名称为“actionbar_背景”

在本例中,脚本将在资源文件夹“drawable”中查找与给定名称匹配的图像。如果电话是

<item name="text">@string/actionbar_title</item>
@string/actionbar\u title

脚本将在res/values中查找定义为带有“name”属性“actionbar\u title”的资源。

在Android的布局文件中,“@”符号后跟类似“drawable”或“style”的单词,表示res或资源文件夹中的路径和文件

@drawable/actionbar\u background
将actionbar的背景设置为可绘制(图像)资源,该资源位于项目->可绘制文件夹中

我想你也可以用颜色来设置你的背景如下:
@android:color/black

那么,actionbar_背景图像是否只是块颜色的图像呢?这取决于文件中的内容:-)android有几套资源,但最重要的两套是你放在应用程序和系统资源中的资源。在上面的示例中,该值引用了一个系统资源,因此如果您想找到它是什么,请从存储库中提取此系统修订版,并在
res/drawable xxxx
目录中查找文件
actionbar\u background
。作为旁注,
drawable
类型资源不必是图像。它也可以是引用图像的XML或仅使用颜色的XML。这让我们可以创建更复杂的背景和行为,而无需编写一行实际代码。