代码改变世界

launcher.xml文件概述

2011-12-01 10:55  tang768168  阅读(431)  评论(0编辑  收藏  举报
好吧,现在我们来看res目录里的布局文件,布局文件都放在layout*目录里。
本以为launcher的layout都放在layout目录里,由于屏幕放置方式的不同会对桌面造成一定的影响,所以google的 android项目组就决定因地制宜。比如当你横着放置屏幕的时候就会使用layout-land目录里的文件来对系统launcher进行布局,竖着屏 幕的时候会使用layout-port内的布局文件来对launcher来布局。
横竖屏幕切换之际,会重新进行布局。那我们就以layout-land目录为例来看吧。
layout-land/launcuer.xml
1 <?xml version="1.0" encoding="utf-8"?>
2  <!-- Copyright (C) 2007 The Android Open Source Project
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15  -->
16
17 <com.android.launcher2.DragLayer
18 xmlns:android="http://schemas.android.com/apk/res/android"
19 xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
20
21 android:id="@+id/drag_layer"
22 android:layout_width="match_parent"
23 android:layout_height="match_parent">
24
25 <include layout="@layout/all_apps"/>
26
27 <!-- The workspace contains 3 screens of cells -->
28 <com.android.launcher2.Workspace
29 android:id="@+id/workspace"
30 android:layout_width="match_parent"
31 android:layout_height="match_parent"
32 android:scrollbars="horizontal"
33 android:fadeScrollbars="true"
34 launcher:defaultScreen="2">
35 <!-- 上面这行可以确定屏幕横放时默认的桌面号 -->
36 <include android:id="@+id/cell1" layout="@layout/workspace_screen"/>
37 <include android:id="@+id/cell2" layout="@layout/workspace_screen"/>
38 <include android:id="@+id/cell3" layout="@layout/workspace_screen"/>
39 <include android:id="@+id/cell4" layout="@layout/workspace_screen"/>
40 <include android:id="@+id/cell5" layout="@layout/workspace_screen"/>
41 </com.android.launcher2.Workspace>
42 <!-- 上面这几行描述了几个工作区的屏幕,描述代码为layout-land/workspace_screen
43
44 而模拟器上能看到左右各两个小白点可以控制工作区的移动
45
46 -->
47
48 <!-- 应该对应的是ClippedImageView类-->
49 <com.android.launcher2.ClippedImageView
50 android:id="@+id/previous_screen"
51 android:layout_width="93dip"
52 android:layout_height="@dimen/button_bar_height"
53 android:layout_gravity="bottom|left"
54 android:layout_marginLeft="6dip"
55
56 android:scaleType="center"
57 android:src="@drawable/home_arrows_left"
58
59 android:onClick="previousScreen"
60
61 launcher:ignoreZone="56dip"
62
63 android:focusable="true"
64 android:clickable="true"/>
65 <!-- 定义了previousScreen 按钮,即左下脚的白色小点,用来控制移动-->
66 <com.android.launcher2.ClippedImageView
67 android:id="@+id/next_screen"
68 android:layout_width="93dip"
69 android:layout_height="@dimen/button_bar_height"
70 android:layout_gravity="bottom|right"
71 android:layout_marginRight="6dip"
72
73 android:scaleType="center"
74 android:src="@drawable/home_arrows_right"
75
76 android:onClick="nextScreen"
77
78 launcher:ignoreZone="-56dip"
79
80 android:focusable="true"
81 android:clickable="true"/>
82 <!-- 底部右边的两个白色小点 -->
83 <com.android.launcher2.DeleteZone
84 android:id="@+id/delete_zone"
85 android:layout_width="@dimen/delete_zone_size"
86 android:layout_height="@dimen/delete_zone_size"
87 android:paddingLeft="@dimen/delete_zone_padding"
88 android:layout_marginBottom="@dimen/half_status_bar_height"
89 android:layout_gravity="right|center_vertical"
90
91 android:scaleType="center"
92 android:src="@drawable/delete_zone_selector"
93 android:visibility="invisible"
94 launcher:direction="vertical"
95 />
96 <!-- 定义Trash放置的位置 右侧,中间平放-->
97 <RelativeLayout
98 android:id="@+id/all_apps_button_cluster"
99 android:layout_height="fill_parent"
100 android:layout_width="@dimen/button_bar_height_portrait"
101 android:layout_gravity="right|center_vertical"
102 android:layout_marginBottom="@dimen/half_status_bar_height"
103 >
104 <!-- 定义右侧 靠近屏幕边缘的三个按钮,中间一个是all-apps
105
106 之下是phone按钮,之上是浏览器按钮,绑定响应函数
107
108 -->
109 <com.android.launcher2.HandleView
110 style="@style/HotseatButton"
111 android:id="@+id/all_apps_button"
112 android:layout_centerVertical="true"
113 android:layout_alignParentRight="true"
114
115 android:src="@drawable/all_apps_button"
116 launcher:direction="vertical"
117 />
118
119 <ImageView
120 android:id="@+id/hotseat_left"
121 style="@style/HotseatButton.Left"
122 android:layout_below="@id/all_apps_button"
123
124 android:src="@drawable/hotseat_phone"
125
126 android:onClick="launchHotSeat"
127 />
128 <!-- onClick的值为响应方法-->
129 <ImageView
130 android:id="@+id/hotseat_right"
131 style="@style/HotseatButton.Right"
132 android:layout_above="@id/all_apps_button"
133
134 android:src="@drawable/hotseat_browser"
135
136 android:onClick="launchHotSeat"
137 />
138 <!-- 对浏览器进行的描述-->
139 </RelativeLayout>
140 </com.android.launcher2.DragLayer>
141
142

 

下面的还没有但是~~~这写就够我先学段时间了哈哈~~~