1.gen目录
里面包含一个重要的文件R.java,该文件由开发Eclipse自动生成,该R类为final修饰不可被继承,里面含有多个内部final类,每个内部类吃都与都记录一个唯一对应的ID编号
/*
* R.java
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
public final class R {
public static final class attr {
}
public static final class id {
public static final int action_settings=0x7f080003;
public static final int button=0x7f080002;
public static final int editText=0x7f080001;
public static final int textView=0x7f080000;
}
public static final class layout {
public static final int activity_main=0x7f030000;
}
public static final class string {
public static final int action_settings=0x7f050001;
public static final int app_name=0x7f050000;
public static final int hello_world=0x7f050002;
}
}
2.assets目录
放入project中的文件,访问次数较少,比如软件启动画面和多媒体资源文件,该文件在R.java中没有自动生成ID,只能通过路径才能访问到资源。
3.res目录
里面的一些文件或者标签应该在R.java文件中自动生成ID
(1).drawable
用于存放image图片,支持png,对于不同分辨率的设备提供了3三不同像素文件,操作系统会根据设备分辨率自动选择合适的图片
(2).layout
在该目录下的每个xml文件都会在R.layout中定义,如果一个Activity的子类的方法oncreate()中使用了setContentView(R.layout.activity_main/*与layout下的xml文件Id对于*/);则activity会根据xml中定义的标签完成activity的界面设计
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:text="test"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_below="@id/textView"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OK"
android:id="@+id/button"
android:layout_below="@id/editText"
android:layout_alignRight="@id/editText"
android:layout_margin="10px"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/button"
android:text="Cancel"
android:layout_toLeftOf="@id/button"/>
</RelativeLayout>
(3).values
该目下的xml文件可以以符合命名规范要求的任意文件名,但内容标签应该符合特定要求。即提高了编译效率,有便于统一对资源进行管理!
<!-- string.xml -->
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Soft</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
</resources>
4.libs目录
存放导入的jar包文件
5.AndroidManifest.xml
AndroidManifest.xml 是每个android程序中必须的文件。它位于整个项目的根目录,描述了package中暴露的组件(activities, services, 等等),他们各自的实现类,各种能被处理的数据和启动位置。 除了能声明程序中的Activities, ContentProviders, Services, 和Intent Receivers,还能指定permissions和instrumentation(安全控制和测试)