桌面快捷方式是保存在手机的 /data/data/com.android.launcher/databases/launcher.db 这个数据库文件下的favorites表中.
几个主要字段:
_id,
title,(快捷方式的名称)
intent,(快捷方式启动的对象)
screen,(快捷方式在哪个屏幕,默认是1)
cellX,cellY,(快捷方式的位置)
iconPackage,iconResource(快捷方式的图标)
另外低版本的SDK是用"content://com.android.launcher.settings/favorites?notify=true"来访问.
sqlite> select * from favorites; 1|Calendar|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.calendar/.LaunchActivity;end|-100|2|3|1|1|1|0|-1||0|||�PNG || 2|Display settings|#Intent;action=android.intent.action.MAIN;category=com.android.settings.SHORTCUT;launchFlags=0x200000;component=com.android.settings/.DisplaySettings;end|-100|2|1|1|1|1|1|-1||0|com.android.settings|com.android.settings:drawable/ic_launcher_settings|�PNG sqlite> .schema CREATE TABLE android_metadata (locale TEXT); CREATE TABLE favorites (_id INTEGER PRIMARY KEY,title TEXT,intent TEXT,container INTEGER,screen INTEGER,cellX INTEGER,cellY INTEGER,spanX INTEGER,spanY INTEGER,itemType INTEGER,appWidgetId INTEGER NOT NULL DEFAULT -1,isShortcut INTEGER,iconType INTEGER,iconPackage TEXT,iconResource TEXT,icon BLOB,uri TEXT,displayMode INTEGER);
SeekBar使用
布局声明 <SeekBar>
定义OnSeekBarChangeListener
实现其中onProgressChanged,onStartTrackingTouch,onStopTrackingTouch
注意onProgressChanged中有一个boolean fromUser参数
绑定监听器
RatingBar使用
布局声明
<RatingBar> 其中有2个特别属性 android:numStars="5"(星数) android:stepSize="1.0"(每次进多少)
定义OnRatingBarChangeListener
实现onRatingChanged 同样包含fromUser参数
绑定监听器
视频里讲得非常简单 但是往往实际操作中 对很多控件的样式有比较高的要求 正好简单用到过一些 作为补充一下
SeekBar为例
最简单的 在布局文件中通过属性定义
android:progressDrawable="@drawable/bar_style" //背景
android:thumb="@drawable/bar" //拖动的按钮
android:thumbOffset="0dip" //如果不是0的话 游标则不是从头开始 会比较奇怪 根据需要设置
而之后如果仍然不能满足要求 可以考虑通过修改drawable selector等进行进一步的定制
例如定义一个自己的drawable作为背景
<?xml version="1.0" encoding="UTF-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background"> <shape> <corners android:radius="5dip" /> <gradient android:startColor="#ff9d9e9d" android:centerColor="#ff5a5d5a" android:centerY="0.75" android:endColor="#ff747674" android:angle="270" /> </shape> </item> <item android:id="@android:id/secondaryProgress"> <clip> <shape> <corners android:radius="5dip" /> <gradient android:startColor="#80ffd300" android:centerColor="#80ffb600" android:centerY="0.75" android:endColor="#a0ffcb00" android:angle="270" /> </shape> </clip> </item> <item android:id="@android:id/progress"> <clip> <shape> <corners android:radius="5dip" /> <gradient android:startColor="#ff0099CC" android:centerColor="#ff3399CC" android:centerY="0.75" android:endColor="#ff6699CC" android:angle="270" /> </shape> </clip> </item> </layer-list>
也可以直接使用预先准备好的图片
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background" android:drawable="@drawable/progress_bg" /> <item android:id="@android:id/secondaryProgress" android:drawable="@drawable/second_progress"> </item> <item android:id="@android:id/progress" android:drawable="@drawable/first_progress"> </item> </layer-list>
也可以对各种状态通过selector进行定义 同样适用于按钮之类的其他控件
<?xml version="1.0" encoding="UTF-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 按下状态--> <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/thumb_pressed" /> <!-- 普通无焦点状态 --> <item android:state_focused="false" android:state_pressed="false" android:drawable="@drawable/thumb_normal" /> <!-- 有焦点状态--> <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/thumb_focused" /> <!-- 有焦点 --> <item android:state_focused="true" android:drawable="@drawable/thumb_focused" /> </selector>
以上图片和xml文件 都放在drawable文件夹下 通过R.drawable.xxx或者在布局中@drawable/xxx.xml等方式引用
code来自于http://www.devdiv.com/thread-46488-1-1.html
这篇blog主要是还原了一下 http://www.iteye.com/topic/1112526
这个效果挺不错,不过已经不是什么新鲜玩意了,ibook和腾讯的qq看书都有实现这个效果,感觉实现起来也不是很难
博主的这个效果没有添加触屏操作,紧紧只有动画,有点小小的遗憾,不过楼主的分享精神还是值得赞许的
博主没有添加Activity类源码和对应xml布局文件,我试着初步还原了一下,还原的还不够好,不过基本效果已经出来了
至少可以根据效果查看一下实现的原理 附上源码 给有用的人