1.Android目录介绍+布局(学习笔记)

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>
a1
a2
b1
b2
--------------------------------------------------------
帧布局
----------------------------------
<FrameLayout>
<ImageView
  android:src="@dravable/movie"  />//电影图片
<ImageView
  android:src="@dravable/play"
 android:layout_gravity="center"(上下左右居中)   />//按钮图片
</FrameLayout>
效果:

------------------------------------
技巧:
ctrl+F11将模拟器屏幕切换横屏
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jsoh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值