[英]What is this Android drawable background resource?
I have just started learning Android, currently going through the tutorials on the Google Android developer website, so far not that impressed as there are a lot of things that go unexplained. 我刚刚开始学习Android,目前正在通过Google Android开发者网站上的教程进行学习,到目前为止,没有印象深刻,因为很多事情无法解释。
On the tutorial "Styling the Action Bar", it has the following XML style resource: 在教程“设置操作栏样式”上,它具有以下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+ support) (支援Android 2.1以上版本)
At no point does it mention what the @drawable/actionbar_background is meant to be? 它从来没有提到@ drawable / actionbar_background是什么意思? As it is @drawable is this an image? 因为它是@drawable,这是图像吗? I wouldn't understand why it would be as it's meant to be colouring the action bar background. 我不明白为什么会这样,因为它是给动作栏背景着色。
Any help would be greatly appreciated!!!!!!! 任何帮助将不胜感激!!!!!!! :) :)
The line 线
<item name="background">@drawable/actionbar_background</item>
translates to English like 像英语一样翻译
Add to this style an item representing a property called "background". 在此样式中添加一个代表“ background”属性的项目。 As the value of this property, set a resource of type "drawable" with name "actionbar_background". 作为此属性的值,将名称为“ actionbar_background”的资源设置为“ drawable”。
In this case the script will look for an image in the resources folder "drawable" the name of which matches the given one. 在这种情况下,脚本将在“可绘制”资源文件夹中查找名称与给定名称匹配的图像。 If the line was 如果线是
<item name="text">@string/actionbar_title</item>
The script would look in res/values for a resource defined as <string>
with "name" property "actionbar_title". 该脚本将在res / values中查找定义为<string>
且资源具有“ name”属性“ actionbar_title”的资源。
In the layout files for Android, the '@' symbol followed by a word like 'drawable' or 'style', refers to a path and file in the res or resource folder. 在Android的布局文件中,“ @”符号后跟诸如“ drawable”或“ style”之类的单词,表示res或resource文件夹中的路径和文件。
http://developer.android.com/guide/topics/resources/drawable-resource.html http://developer.android.com/guide/topics/resources/drawable-resource.html
<item name="android:background">@drawable/actionbar_background</item>
sets your actionBar's background to drawable(image) resource which is located in your project -> drawable folders. <item name="android:background">@drawable/actionbar_background</item>
的背景设置为位于项目-> drawable文件夹中的drawable(image)资源。
I guess you can also use color to set your background like this: <item name="android:background">@android:color/black</item>
我想您也可以使用color这样设置背景: <item name="android:background">@android:color/black</item>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.