转载:http://www.cnblogs.com/hibraincol/archive/2011/10/27/2227149.html
今天在看android froyo的launcher2 源码的时候,在launcher.xml中看到有这么一段代码:
<
com.android.launcher2.DragLayer
xmlns:android
=
"http://schemas.android.com/apk/res/android"
xmlns:launcher
"http://schemas.android.com/apk/res/com.android.launcher"
android:id
"@+id/drag_layer"
android:layout_width
"match_parent"
android:layout_height
"match_parent"
>
include
layout
"@layout/all_apps"
/>
<!-- The workspace contains 3 screens of cells -->
com.android.launcher2.Workspace
"@+id/workspace"
"match_parent"
"match_parent"
android:scrollbars
"horizontal"
android:fadeScrollbars
"true"
launcher:defaultScreen
"2"
>
|
注意到其中的两处:
xmlns:launcher=”http://schemas.android.com/apk/res/com.android.launcher”
和
launcher:defaultScreen="2"
以前没遇到过,既然这里碰到了,就顺便学习下,下面就写个简单的示例,权当学习笔记,便于以后查阅。
建立一个属性xml文件: values/attrs.xml,内容如下:
>
name
"relation"
>
"icon_left"
value
"0"
/>
"1"
/>
/>
"3"
/>
attr
>
/>
"IconText"
>
format
"reference"
/>
"string"
/>
"dimension"
/>
"integer"
/>
/>
>