eclipse所创工程的目录:

src 源代码

gen R文件 注册资源ID (不用IO)

assets 用来存放不需要编译的资源 (可以存在文件夹)

bin apk

libs 用来存放外部的库

res 资源 会在R文件中注册 (命名: 字母:小写 _ 数字 ;数字不能开头)

drawable 图片

layout 布局 xml : <名称 属性=值> </名称> <名称 属性=值/>

menu 菜单的布局

valuse 长度 字符串 风格

raw 存放不想编译的资源(不能新建文件夹、会在R文件中注册)

AndroidManifest.xml 清单文件

问题解决:

1、FC

出现错误,是否强制关闭

2、日志 LogCat

verbose 所有信息 Log.v(String str,String str); //黑色

debug 调试的信息 //蓝色

info

warn

erro 红色

assert 断言

3、解决FC

1、看日志

2、看出错的原因

3、找出错的代码

从上往下找第一出现自己写的代码的位置

一般情况下是在Caused by 下面第一句

4、双击定位过去

4、工程出错

重新编译

5、R出错

1、资源问题 (资源命名问题 a~z _ 数字 数字不能开头)

2、R文件导入错误(可以导入了 android.R)

3、编译(忘了自动编译)

a、Project ---> Build Auto…… 要勾上

b、重新编译

Project ---> Clean

6、拖动控件出现 ClassCastException

Project ---> Clean



Genymotion的使用:(极速模拟器)

Genymotion + VirtualBox

使用步骤:

1、安装

2、安装完成之后打开Genymotion,打开完成之后关闭

3、把镜像文件copy到

C:\Users\admintor\AppData\Local\Genymobile

覆盖掉

4、

ImageView 存放图片

<ImageView

android:id="@+id/p_w_picpathView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/ic_launcher"

//前景图片

android:scaleType="center"

//center 居中

//fitxy 拉伸适应控件大小

//fitStar 从左上角为原点拉伸(图片比例不会改变)

/>

code:

//设置前景图片

p_w_picpathView.setImageResource(R.drawable.ic_launcher);

//设置背景

p_w_picpathView.setBackgroundResource(R.drawable.ic_launcher);

//设置拉伸模式

p_w_picpathView.setScaleType(ScaleType.FIT_XY);

ImageButton

ImageView的子类

布局管理器:

1、LinearLayout 线性布局

<LinearLayout
android:orientation="horizontal"

//方向 值:horizontal 水平方向

vertical 垂直方向

>

特殊属性:

只有当控件放在LinearLayout中这个属性才生效

android:layout_weight="2"

//权重 分割剩余空间

android:layout_gravity="center"

值: 上下左右 居中(水平居中、垂直居中)

通用属性:

控件在任何布局中都有的属性

//设置控件跟内容之间的间隙

android:padding="20dp" //上下左右

android:paddingLeft="10dp" 左

android:paddingRight="20dp" 右

android:paddingTop="30dp" 上

android:paddingBottom="40dp" 下

控件之间的间隙

android:layout_margin="20dp" //上下左右

android:layout_marginLeft="10dp"

android:layout_marginRight="20dp"

android:layout_marginTop="30dp"

android:layout_marginBottom="40dp"


内容在控件中的对齐方式

android:gravity="top|right"


RelativeLayout 相对布局


控件在布局中的对齐方式

android:layout_alignParentLeft="true" 左对齐

android:layout_alignParentTop="true" 上对齐

android:layout_alignParentRight="true" 右

android:layout_alignParentBottom="true" 下

android:layout_centerHorizontal="true" 水平居中

android:layout_centerVertical="true" 垂直居中

android:layout_centerInParent="true" 居中


控件之间的对齐方式

android:layout_alignTop="@+id/textView2" 上

android:layout_alignLeft="@+id/textView2" 左

android:layout_alignRight="@+id/textView2" 右对齐

android:layout_alignBottom="@+id/textView2" 下对齐


控件之间的位置关系:

android:layout_above="@+id/tf" 在xx之上

android:layout_toLeftOf="@+id/tf" 在 左边

android:layout_toRightOf="@+id/tf" 右边

android:layout_below="@+id/tf" 在xx之下


FrameLayout 帧布局

特性:层叠控件

android:layout_gravity="right|top"


TableLayout 表格布局

每一行都是 tablerow

高度是由每一行中高度最高的那个控件决定

宽度是由每一列中宽度最宽的那个控件决定


AbsoluteLayout 绝对布局 (不建议使用)




GridLayout 网格布局 (4.0之后新增)

android:layout_column="2"

android:layout_row="3" //声明控件所在的行列


android:layout_columnSpan="2"

android:layout_rowSpan="2" //声明控件所占用的行列



布局是可以进行嵌套的。