- 浏览: 151523 次
- 来自: 深圳
最新评论
-
ritterliu:
您好,这个问题麻烦您看下http://topic.csdn.n ...
Android 2.2的锁屏界面修改 -
lnb333666:
不知道飞扬兄可否有空,可否加QQ339579300联系,想向您 ...
Android 2.2的锁屏界面修改 -
飞扬云:
black_smart 写道飞扬云 写道black_smart ...
Android 2.2的锁屏界面修改 -
black_smart:
飞扬云 写道black_smart 写道飞扬兄,你好! 我现在 ...
Android 2.2的锁屏界面修改 -
飞扬云:
black_smart 写道飞扬兄,你好! 我现在也在做锁屏这 ...
Android 2.2的锁屏界面修改
Android 2.2的锁屏界面如图1所示,左右两侧是2个滑动条,正常状态下左边的是解锁,右边的是声音的开关,来电话时,左边是接听电话的解锁,右边是不接听来电的解锁。
text:当拖动左边的滑动条时,会出现“Unlock”文本,就是这个text。如图5所示。
图5
target: 当触摸到这个滑动条时,左、右边会各有一个点,就是目标点target,他起到一个临界指示作用,每次拖动滑动条达到这个临界点时就会触发解锁事件,解锁结束后就可以使用主界面了。如图6所示。要注意的是:这个目标点只是起到临界指示作用,没有别的含义。真正的临界点时看不见的,为了起到一个视觉的认识,在这里就使用这样一个目标点来代表临界点,下面会在代码中解释真正的临界点在哪里。
图6
在这个Slider内部类中有一个布局方法:void layout(int l, int t, int r, int b, int alignment)
核心代码是:
if (alignment == ALIGN_LEFT || alignment == ALIGN_RIGHT) {
// horizontal
Log.i(TAG,"Is this horizontal ?");
final int targetTop = (parentHeight - targetHeight) / 2;
final int targetBottom = targetTop + targetHeight;
final int top = (parentHeight - handleHeight) / 2;
final int bottom = (parentHeight + handleHeight) / 2;
if (alignment == ALIGN_LEFT) {
Log.i(TAG,"Is this leftBar? ");
// modified by zhuluofeng 2011-11-15
// 0 to 0+50,leftTarget to leftTarget+500
tab.layout(0, top, handleWidth, bottom);
text.layout(0 - parentWidth, top, 0, bottom);
text.setGravity(Gravity.RIGHT);
target.layout(leftTarget, targetTop, leftTarget + targetWidth, targetBottom);
Log.i(TAG,"targetTop is: " + targetTop);
Log.i(TAG,"targetBottom is: " + targetBottom);
alignment_value = l;
} else {
Log.i(TAG,"Is this RightBar?");
tab.layout(parentWidth - handleWidth, top, parentWidth, bottom);
text.layout(parentWidth, top, parentWidth + parentWidth, bottom);
target.layout(rightTarget, targetTop, rightTarget + targetWidth, targetBottom);
text.setGravity(Gravity.TOP);
alignment_value = r;
}
} else {
// vertical
Log.i(TAG,"Is this vertical ?");
final int targetLeft = (parentWidth - targetWidth) / 2;
final int targetRight = (parentWidth + targetWidth) / 2;
final int top = (int) (THRESHOLD * parentHeight) + handleHeight / 2 - targetHeight;
final int bottom = (int) ((1.0f - THRESHOLD) * parentHeight) - handleHeight / 2;
if (alignment == ALIGN_TOP) {
Log.i(TAG,"Is this TopBar ?");
tab.layout(left, 0, right, handleHeight);
text.layout(left, 0 - parentHeight, right, 0);
target.layout(targetLeft, top, targetRight, top + targetHeight);
alignment_value = t;
} else {
Log.i(TAG,"Is this BottomBar ?");
// modified by zhuluofeng 2011-11-15
// bottom to bottom+500, parentHeight - handleHeight to parentHeight - handleHeight-50
// the bottom is the right side
tab.layout(left, parentHeight - handleHeight, right, parentHeight);
text.layout(left, parentHeight, right, parentHeight + parentHeight);
target.layout(targetLeft, bottom, targetRight, bottom + targetHeight);
Log.i(TAG,"the vertical bottom is: " + bottom);
Log.i(TAG,"the vertical targetHeight is: " + targetHeight);
alignment_value = b;
}
}
这段代码其实就一个if else控制语句,if (alignment == ALIGN_LEFT || alignment == ALIGN_RIGHT) 表示:
手机处在竖屏时(即滑动条处在水平方向),如果拖动左边的滑动条或者拖动右边的滑动条时的处理方法。
else中的代码表示手机处于横屏时(即滑动条处在竖直方向),如果拖动下面的滑动条或者拖动上面的滑动条的处理方法。
在大的if语句中包含了一个if else语句,if表示的是左边的滑动条,else就是右边的滑动条;在大得else语句中也包含了一个if else语句,if表示的是竖直方向的上面的滑动条,else表示的是竖直方向的下面的滑动条。
理解了这一点就很容易定位到具体的滑动条的代码了。
先修改当手机处在竖直方向时(即滑动条处在水平方向)左边的解锁滑动条的距离,目标点的距离。
a) 将左边的滑动条tab向右边移动下
看上面紫红颜色的代码,将andleWidth加上一个数值即可,比如我们加上50变成:
tab.layout(0, top, handleWidth + 50, bottom);
那这几个参数是什么意思呢?
public void layout (int l, int t, int r, int b)
Assign a size and position to a view and all of its descendants
This is the second phase of the layout mechanism. (The first is measuring). In this phase, each parent calls layout on all of its children to position them. This is typically done using the child measurements that were stored in the measure pass().
Derived classes should not override this method. Derived classes with children should override onLayout. In that method, they should call layout on each of their children.
Parameters
Left position, relative to parent |
Top position, relative to parent |
Right position, relative to parent |
Bottom position, relative to parent
|
评论
http://topic.csdn.net/u/20120730/15/8d3dacf2-7196-4e5e-a325-0e16a87208f6.html
我现在已经不在做UI这一块了,不过可以讨论,交流,谢谢。。。
我现在 需要做一个仿htc的滑动锁屏界面,由于刚接触不久 ,也没有很好的思路,能否指点一二呢?(直接在framework里面修改的话感觉改动挺大的,而且不知道怎样去实现)
:)
一般来说,源码那么大,全面掌握太难,我这里基本上就是在做项目中熟悉基本架构,然后学会使用grep find命令去搜索,这样就很容易定位到某个文件。比如:如果你看到某个图片,先可以在目录下查找,找到后,可以通过这个图片得名子去搜索和这个图片相关的文件。你查看多了,自然就会了解目录结构了。一般来说,图片和各种在资源在framework以及package下面的res里面。好了,这也是我大概学习的过程,仅供参考。你多和你同事沟通,时间长了,肯定有自己的方法。。。如果有好的方法,还请提供一下,互相学习。。。
我现在已经不在做UI这一块了,不过可以讨论,交流,谢谢。。。
我现在 需要做一个仿htc的滑动锁屏界面,由于刚接触不久 ,也没有很好的思路,能否指点一二呢?(直接在framework里面修改的话感觉改动挺大的,而且不知道怎样去实现)
我现在已经不在做UI这一块了,不过可以讨论,交流,谢谢。。。
相关推荐
android2.2源码编译-Ubuntu10.04 (X86) + android2.2 + JDK1.6android2.2源码编译-Ubuntu10.04 (X86) + android2.2 + JDK1.6android2.2源码编译-Ubuntu10.04 (X86) + android2.2 + JDK1.6
Android2.2通讯录源码,系统自带的
android2.2源码 安卓2.2系统源代码 内附使用说明
MyEclipse Android2.2- 2.3 开发环境搭建、配置 (基于Win 7、xp、win2003操作系统) 一、基本步骤概览 1、安装MyEclipse8.5 (集成了Eclipse 3.5.2) 2、安装和配置Android SDK 2.2 3、安装ADT 4、配置...
Google在旧金山Moscone会展中心举办Google I/O 2010大会第二天(美国时间5月20日上午)的会议之上如约正式发布了代号为“Froyo(冻酸奶)”的最新版Android 2.2操作系统。据官 方介绍,新版系统带来性能的大幅度提升,...
lockscreen application for android 2.2
android 2.2 源代码 关联eclipse使用超爽
android2.2 adb工具; 适用于大部分机子(中兴v880测试通过)。
Android 2.2 API 中文文档
android2.2sdk1共2个 android2.2sdk1共2个android2.2sdk1共2个
在SDK的安装文件目录中的android 2.2中新建一个sources文件夹,将下载的源代码解压到此文件夹中,重启eclipse即可。一下路径为本人的SDK安装目录: E:\android\android-sdk-windows\platforms\android-8\sources
android2.2 源码 覆盖网络应用 界面操作 后台管理 直接导入就可以用了
android2.2 录音程序完整源码,代码不多,没有多余的功能和代码,适合新手学习用。
Android 2.2 API中文文档合集,涵盖了目前国内android翻译组全部文档,包括android 2.2,2.3的绝大部分API文档,内部doc文件近100篇,可供学习设计参考。
android2.2通讯录操作源代码,经验证可行。欢迎使用
Android 2.2 即 API-8 的源代码。 用7zip格式压缩,120多M的东西压得只有10几M了。
eclipse时,debug中经常会遇到source not ...一般的解决方法是将android源代码,添加到D:\Android\android-sdk-windows\platforms\android-8中,本资源分为四个部分,一并下载后解压合并即可android2.2源代码(part1)
android 2.2 中文排序包.....
Android4.0新增了一个开关按钮,Switch,但是只能在4.0以上使用,该项目改写了Switch使其支持Android2.2
Android 2.2 源码 ,android-2.2-froyo-src.zip/android-2.2-froyo-src.zip