1.Android目录介绍+布局(学习笔记)
2015-01-18 11:35
453 查看
src 文件下: 存放java源文件
gen文件下: 存放由开发自动生成的文件-》R.java(用于各种资源的id,不用程序员维护)
res 文件下:存放资源文件,图片,软件界面,软件使用到的文字。
res下drawable 放图像资源
res下layout:存放软件界面(UI)界面。(xxx.xml)
res下values:存放应用中使用到文字,尺寸。方便以后实现国际化和减少存储空间。
assets:存放资源,但不是在R.java中生成id,使用需要指定文件的路径。
AndroidManifest.xml项目清单文件:
文件累出应用程序所提供的功能,以后开发好的各种组件(Activity,ContentProvider,BroadcastReceiver、Service)需要在该文件中进行配置,如果应用使用到了系统内置的应用(如打电话default.proerties项目环境信息,一般是不需要修改此文件)
-----------------------------------------
android:icon=“@dravable/icon”
<activity android name=“.MainActivity”>
</activity>--》界面
------------------------------------------
<intent-filter>
意图处理器:匹配意图
<action android:name="intent.action.MAIN"/>代表一个功能(程序的入口)
<category android:name="android.intent.category.LAUNCHER"/>代表在程启动列表中显示
</intent-filter>只可以应用在一个activity中。
--------------------------------------------
apk怎么形成的。
.java---》.class--dx-》.dex----》打包---》apk文件
-------------------------------------------
创建进程-创建主线程-在主线程中实例化Acivity-(操作系统会把应用有关的信息(Content)存进Activity中,然后调用onCreate())
-----------------------------------------
setContentView(R.layout.main);传入资源界面的id。通过这个api把这个界面显示出来。
-------------------------------------------
线性布局LinearLayout
代码:
<LinearLayout xmls:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical-》垂直方向“
android:layout_width="fill_parent" (fill_parent:与父容器一样,也就是到它的边界)
android:layout_height="fill_parent"
>
-------------------------------------------------------------------------------------------------------------------
相对布局
-------------------------
above
在xx上面
below
在xx下面
toLeftOf
在xx左
toRighteOf
在xx的右
aligin_ 与xx对齐
margin_ 间隙(顶,左,右)
-----------------------
设置背景 android:background="@android:drawable/editbox_background"
//访问android包下R文件(操作系统下R.java )
在XX左边
android:layout_toLeftOf="@id/ok"//在ok按钮的左边
在XX下面
android:layout_below="@id/label" //below在什么(label)下面
靠齐父元素(相对布局)右边
android:layout_alignParentRight="true"
与xx靠顶对齐
android:layout_aliginTop="@id/ok"//这个按钮和ok按钮顶边对齐
控件与控件的间隙,这里定义左边的间隙
android:layout_marginLeft="10px"
-----------------------
<RelativeLayout
android:background="@drawable/bule" 包括(图片,颜色,状态列表,动画)
android:padding="10px"控件里的内容控件距离的距离(内间距)。
>代码:
<TextView android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Type here:"
/>
<EditText android:id="@+id/entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background" //访问android包下R文件(操作系统下R.java )
android:layout_below="@id/label" //below在什么(label)下面
/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/entry"
android:layout_alignParentRight="true"//靠齐父元素(相对布局)右边
android:layout_marginLeft="10px"//控件与控件的间隙,这里定义左边的间隙
android:text="ok"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_ontetnt"
android:layout_toLeftOf="@id/ok" //要求在ok按钮的左边
android:layout_aliginTop="@id/ok"//这个按钮和ok按钮顶边对齐
android:text="Cancel"
/>
</RelativeLayout>
---------------------------------------------------------------------------------
表格布局
------------------------
<TableLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">//是否允许表格拉伸
<TableRow>//第一行
<TextView />//第一列a1
<TextView />//第一列a2
</TableRow>
<TableRow>//第二行
<TextView />//第一列b1
<TextView />//第一列b2
</TableRow>
</TableLayout>
--------------------------------------------------------
帧布局
----------------------------------
<FrameLayout>
<ImageView
android:src="@dravable/movie" />//电影图片
<ImageView
android:src="@dravable/play"
android:layout_gravity="center"(上下左右居中) />//按钮图片
</FrameLayout>
效果:
------------------------------------
技巧:
ctrl+F11将模拟器屏幕切换横屏
gen文件下: 存放由开发自动生成的文件-》R.java(用于各种资源的id,不用程序员维护)
res 文件下:存放资源文件,图片,软件界面,软件使用到的文字。
res下drawable 放图像资源
res下layout:存放软件界面(UI)界面。(xxx.xml)
res下values:存放应用中使用到文字,尺寸。方便以后实现国际化和减少存储空间。
assets:存放资源,但不是在R.java中生成id,使用需要指定文件的路径。
AndroidManifest.xml项目清单文件:
文件累出应用程序所提供的功能,以后开发好的各种组件(Activity,ContentProvider,BroadcastReceiver、Service)需要在该文件中进行配置,如果应用使用到了系统内置的应用(如打电话default.proerties项目环境信息,一般是不需要修改此文件)
-----------------------------------------
android:icon=“@dravable/icon”
<activity android name=“.MainActivity”>
</activity>--》界面
------------------------------------------
<intent-filter>
意图处理器:匹配意图
<action android:name="intent.action.MAIN"/>代表一个功能(程序的入口)
<category android:name="android.intent.category.LAUNCHER"/>代表在程启动列表中显示
</intent-filter>只可以应用在一个activity中。
--------------------------------------------
apk怎么形成的。
.java---》.class--dx-》.dex----》打包---》apk文件
-------------------------------------------
创建进程-创建主线程-在主线程中实例化Acivity-(操作系统会把应用有关的信息(Content)存进Activity中,然后调用onCreate())
-----------------------------------------
setContentView(R.layout.main);传入资源界面的id。通过这个api把这个界面显示出来。
-------------------------------------------
线性布局LinearLayout
代码:
<LinearLayout xmls:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical-》垂直方向“
android:layout_width="fill_parent" (fill_parent:与父容器一样,也就是到它的边界)
android:layout_height="fill_parent"
>
-------------------------------------------------------------------------------------------------------------------
相对布局
-------------------------
above
在xx上面
below
在xx下面
toLeftOf
在xx左
toRighteOf
在xx的右
aligin_ 与xx对齐
margin_ 间隙(顶,左,右)
-----------------------
设置背景 android:background="@android:drawable/editbox_background"
//访问android包下R文件(操作系统下R.java )
在XX左边
android:layout_toLeftOf="@id/ok"//在ok按钮的左边
在XX下面
android:layout_below="@id/label" //below在什么(label)下面
靠齐父元素(相对布局)右边
android:layout_alignParentRight="true"
与xx靠顶对齐
android:layout_aliginTop="@id/ok"//这个按钮和ok按钮顶边对齐
控件与控件的间隙,这里定义左边的间隙
android:layout_marginLeft="10px"
-----------------------
<RelativeLayout
android:background="@drawable/bule" 包括(图片,颜色,状态列表,动画)
android:padding="10px"控件里的内容控件距离的距离(内间距)。
>代码:
<TextView android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Type here:"
/>
<EditText android:id="@+id/entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background" //访问android包下R文件(操作系统下R.java )
android:layout_below="@id/label" //below在什么(label)下面
/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/entry"
android:layout_alignParentRight="true"//靠齐父元素(相对布局)右边
android:layout_marginLeft="10px"//控件与控件的间隙,这里定义左边的间隙
android:text="ok"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_ontetnt"
android:layout_toLeftOf="@id/ok" //要求在ok按钮的左边
android:layout_aliginTop="@id/ok"//这个按钮和ok按钮顶边对齐
android:text="Cancel"
/>
</RelativeLayout>
---------------------------------------------------------------------------------
表格布局
------------------------
<TableLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">//是否允许表格拉伸
<TableRow>//第一行
<TextView />//第一列a1
<TextView />//第一列a2
</TableRow>
<TableRow>//第二行
<TextView />//第一列b1
<TextView />//第一列b2
</TableRow>
</TableLayout>
a1 | a2 |
b1 | b2 |
帧布局
----------------------------------
<FrameLayout>
<ImageView
android:src="@dravable/movie" />//电影图片
<ImageView
android:src="@dravable/play"
android:layout_gravity="center"(上下左右居中) />//按钮图片
</FrameLayout>
效果:
------------------------------------
技巧:
ctrl+F11将模拟器屏幕切换横屏
相关文章推荐
- android 学习笔记1-介绍 环境 简单布局
- Android 学习笔记3---Android 工程目录介绍&程序执行过程
- Android用户界面设计——关于布局的学习笔记
- Stoned Bootkit v2学习笔记之infector(友情赠送SBv2磁盘布局介绍)
- Android开发学习笔记(五)Android五大布局
- Android应用开发学习笔记之相对布局
- android 学习教程(三)之---工程目录结构介绍
- android 学习笔记(八)building system8.4 android源码目录结构(下)
- Android开发入门之学习笔记(三):程序窗口的布局
- Stoned Bootkit v2学习笔记之infector(友情赠送SBv2磁盘布局介绍)
- Android应用开发学习笔记之表格布局
- Android 学习笔记 (3)界面布局
- OrmLite For Android 学习笔记 之一 Ormlite 介绍及使用
- 学习笔记-翻译资料:Android 2.3.3 近场通信NFC介绍(本人翻译的)
- 学习笔记-翻译资料:Android 2.3.3 近场通信NFC介绍
- 学习笔记-翻译资料:Android 2.3.3 近场通信NFC介绍(本人翻译的)
- android开发学习笔记(8)Android项目目录结构:
- 学习笔记-翻译资料:Android 2.3.3 近场通信NFC介绍 3ff0
- 活动目录介绍学习笔记
- Linux学习笔记:Linux 系统目录介绍