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

What is this Android drawable background resource?

我刚刚开始学习 Android,目前正在阅读 Google Android 开发者网站上的教程,到目前为止还没有留下深刻的印象,因为有很多东西需要改进无法解释。

在教程 "Styling the Action Bar" 上,它具有以下 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>

(Android 2.1+ 支持)

它从来没有提到@drawable/actionbar_background 是什么意思?因为它是@drawable,所以这是一张图片吗?我不明白为什么会这样,因为它意味着要为操作栏背景着色。

任何帮助将不胜感激!!!!!!! :)

<item name="background">@drawable/actionbar_background</item>

翻译成英文就像

Add to this style an item representing a property called "background". As the value of this property, set a resource of type "drawable" with name "actionbar_background".

在这种情况下,脚本将在资源文件夹 "drawable" 中查找与给定名称匹配的图像。如果该行是

<item name="text">@string/actionbar_title</item>

脚本会在 res/values 中查找定义为 <string> 和 "name" 属性 "actionbar_title".

的资源

在 Android 的布局文件中,'@' 符号后跟 'drawable' 或 'style' 之类的词,指的是 res 或资源文件夹中的路径和文件.

http://developer.android.com/guide/topics/resources/drawable-resource.html

<item name="android:background">@drawable/actionbar_background</item> 将 actionBar 的背景设置为位于项目 -> 可绘制文件夹中的可绘制(图像)资源。

我想你也可以像这样使用颜色来设置你的背景: <item name="android:background">@android:color/black</item>