1: In a nutshell, Android resources refer to non-code parts, slices, MP3, strings, XML files, etc.
2: In an Android project, and the SRC source file has two folders, respectively called Res and assets, these two files are to save the resource file.
Different points:
(1) Res resources can be accessed through the R resource class. This method is more commonly used in Android.
Res contains subfolders that categorize resources:
Anim (XML animation file), drawable (image), layout (layouts file), menu (menus), raw (binary) values (constant value), XML (XML file)
(2) Assets in general is the original files, such as: MP3 files, Android programs can not directly through the R resource class access. Must be read in binary form through the Assertmanager class.
3:res Resource Acquisition Method
(1) In code: the Getresources () method of the context obtains the resources object, which provides a way to obtain various types of resource.
(2) References to resources in other resources
@[Package Name:] Resource type/resource name
R. Resource type. Resource Name
Configuring the background color in XML
<relativelayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Xmlns:tools= "Http://schemas.android.com/tools"
Tools:context= ". Mainactivity "
android:background= "@color/bg_color" >
<textview
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:text= "@string/hello_world"
Android:textcolor= "@color/text_color"/>
</RelativeLayout>
Change background color in Java
This.getwindow (). Setbackgrounddrawableresource (R.color.bg_color);
Android Learning: Resource Management