<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>夜半难眠</title>
	<atom:link href="http://www.havenliu.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.havenliu.com</link>
	<description>记录点生活的无奈</description>
	<lastBuildDate>Thu, 29 Dec 2011 03:25:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>密码泄漏不完全总结</title>
		<link>http://www.havenliu.com/goodarticle/688.html</link>
		<comments>http://www.havenliu.com/goodarticle/688.html#comments</comments>
		<pubDate>Thu, 29 Dec 2011 03:25:16 +0000</pubDate>
		<dc:creator>Haven</dc:creator>
				<category><![CDATA[网络文摘]]></category>

		<guid isPermaLink="false">http://www.havenliu.com/goodarticle/688.html</guid>
		<description><![CDATA[国家嚷嚷了多年的实名制上网一直迟迟不能实现，这回好了，全民都实现实名制上网了。
以下数据转自互联网：
12月21日：CSDN 640W用户帐户，密码，邮箱遭到黑客泄露
12月22日：中国各大知名网站全面沦陷.涉及范围甚广，泄露信息涉及用户相关业务甚多&#8230;. 一场席卷全中国的密码安全问题爆发了&#8230;.
12月23日：经过确认 CSDN 泄露 多玩 泄露 梦幻西游帐户通过木马泄露 人人网部分泄露
12月23日：网友爆料 天涯沦陷&#8230;7K7K包中包含天涯帐户密码!!!互联网安全何在???
12月24日：178沦陷 UUU9沦陷 事态蔓延&#8230;
12月24日：天涯全面沦陷 泄露多达900W帐户信息&#8230;
12月24日：网易土木在线也沦陷，数据量惊人&#8230;
12月25日：百度疑因帐号开放平台泄露帐户信息&#8230;
12月25日：北京麒麟网信息科技有限公司疑泄露百度与PPLive帐户与密码.并且自身帐户信息全部泄露&#8230;
12月25日：UUU9.COM被黑客两次拖库..
12月25日：事态升级天涯疑泄露4000W用户资料
12月25日：178第二次被拖库泄露数据110W条
12月25日：木蚂蚁被爆加密密文用户数据，约13W数据
12月25日：知名婚恋网站5261302条帐户信息证实&#8230;
12月26日：myspace泄露，迅雷又成功离线3个泄露包!
12月26日：ispeak泄露帐户信息 已验证!请官方通知会员修改密码!
12月26日：网络流传包17173.7z中17173.0为178帐户信息，178惨被拖库3次
12月26日：网络流传包17173.7z中17173.3为UUU9.COM帐户信息，泄露数据不详
12月26日：塞班智能手机网校验准确率高达70%！！或塞班智能手机网沦陷
12月27日：网易土木论坛通过碰撞分析密码，用户资料全部属实！共计135文件，4.31G 资料泄露时间疑为2011-07-09 15：09：11(已论坛发帖通知，厂商未回应.)
12月27日：178.com彻底沦陷，共计泄露超出1100W+ 数据!
12月27日：766验证泄露，泄露数据十余万！
12月27日：ys168验证泄露，泄露数据三十余万！
12月27日：凡客20W 当当10W 卓越20W 用户资料验证泄露
12月28日：太平洋电脑泄露200W用户资料包含用户帐户
12月28日：大学数据库泄露，身份证信息泄露，更为敏感内容糟骇客泄露，泄露数据不详，只能靠截图揣摩!
以下为本次账号泄露情况的基本信息表：
CSDN共计泄露640万个帐号，泄漏信息：帐号、明文密码、电子邮件；
多玩：共计泄露800万个帐号，泄漏信息：帐号、MD5加密密码、部分明文密码，电子邮件，多玩昵称；
178.COM：共计泄露188万个账号，泄漏信息：帐号、MD5加密密码、全部明文密码、电子邮件、178昵称(178账户通用NGA)
天涯：共计泄露4000万个帐号(预计超过4000W数据)，泄漏信息：帐号、明文密码、电子邮件
人人网：共计泄露500万个帐号，泄漏信息：明文密码、电子邮件
UUU9.COM：共计泄露700万个帐号，泄漏信息：帐号、MD5加密密码、全部明文密码、电子邮件、U9昵称
网易土木在线：约4.3GB 137个文件，泄漏信息：帐号、MD5加密密码、其他相关数据
梦幻西游：约1.4G(木马盗取)，泄漏信息：帐号、邮箱、明文密码、角色名称、所在服务器、最后登陆时间、最后登陆IP。
北京麒麟网信息科技有限公司：共计泄露9072966个帐号，泄漏信息：帐户、明文密码
知名婚恋网站：共计泄露5261302个帐号，泄漏信息：帐户、明文密码
Ispeak.CN：共计泄露1680271个帐号，泄漏信息：帐户、明文密码、昵称
木蚂蚁：共计泄露13W帐号，泄漏信息：帐户、加密密码、数据库排序ID、其他信息
塞班论坛：共计泄露约140W帐号 泄漏信息：帐户、明文密码、电子邮箱
766.COM：共计泄露约12W帐号，泄漏信息：帐户、md5(md5(pwd).salt)密码、salt、电子邮箱、数据库排序ID
ys168：共计泄露约30W帐号，泄漏信息：帐户、明文、电子邮箱
当当：共计泄露约10W用户资料，泄漏信息：真实姓名、电子邮件、家庭住址、电话
凡客：共计泄露约20W用户资料，泄漏信息：真实姓名、电子邮件、家庭住址、电话
卓越：共计泄露约20W用户资料，泄漏信息：真实姓名、电子邮件、家庭住址、，电话
随机文章2009年12月10日 -- MyEclipse 7.5,MyEclipse 8.0中安装Flex插件2009年07月12日 -- 2009年第96届环法自行车赛第七、八站视频2010年08月19日 -- 青海湖骑行2010年11月2日 -- 杭州九溪烧烤2011年01月7日 -- 【火车票验证精灵】完成了]]></description>
			<content:encoded><![CDATA[<p><font color="#f79646">国家嚷嚷了多年的实名制上网一直迟迟不能实现，这回好了，全民都实现实名制上网了。</font></p>
<p>以下数据转自互联网：</p>
<p>12月21日：CSDN 640W用户帐户，密码，邮箱遭到黑客泄露</p>
<p>12月22日：中国各大知名网站全面沦陷.涉及范围甚广，泄露信息涉及用户相关业务甚多&#8230;. 一场席卷全中国的密码安全问题爆发了&#8230;.</p>
<p>12月23日：经过确认 CSDN 泄露 多玩 泄露 梦幻西游帐户通过木马泄露 人人网部分泄露</p>
<p>12月23日：网友爆料 天涯沦陷&#8230;7K7K包中包含天涯帐户密码!!!互联网安全何在???</p>
<p>12月24日：178沦陷 UUU9沦陷 事态蔓延&#8230;</p>
<p>12月24日：天涯全面沦陷 泄露多达900W帐户信息&#8230;</p>
<p>12月24日：网易土木在线也沦陷，数据量惊人&#8230;</p>
<p>12月25日：百度疑因帐号开放平台泄露帐户信息&#8230;</p>
<p>12月25日：北京麒麟网信息科技有限公司疑泄露百度与PPLive帐户与密码.并且自身帐户信息全部泄露&#8230;</p>
<p>12月25日：UUU9.COM被黑客两次拖库..</p>
<p>12月25日：事态升级天涯疑泄露4000W用户资料</p>
<p>12月25日：178第二次被拖库泄露数据110W条</p>
<p>12月25日：木蚂蚁被爆加密密文用户数据，约13W数据</p>
<p>12月25日：知名婚恋网站5261302条帐户信息证实&#8230;</p>
<p>12月26日：myspace泄露，迅雷又成功离线3个泄露包!</p>
<p>12月26日：ispeak泄露帐户信息 已验证!请官方通知会员修改密码!</p>
<p>12月26日：网络流传包17173.7z中17173.0为178帐户信息，178惨被拖库3次</p>
<p>12月26日：网络流传包17173.7z中17173.3为UUU9.COM帐户信息，泄露数据不详</p>
<p>12月26日：塞班智能手机网校验准确率高达70%！！或塞班智能手机网沦陷</p>
<p>12月27日：网易土木论坛通过碰撞分析密码，用户资料全部属实！共计135文件，4.31G 资料泄露时间疑为2011-07-09 15：09：11(已论坛发帖通知，厂商未回应.)</p>
<p>12月27日：178.com彻底沦陷，共计泄露超出1100W+ 数据!</p>
<p>12月27日：766验证泄露，泄露数据十余万！</p>
<p>12月27日：ys168验证泄露，泄露数据三十余万！</p>
<p>12月27日：凡客20W 当当10W 卓越20W 用户资料验证泄露</p>
<p>12月28日：太平洋电脑泄露200W用户资料包含用户帐户</p>
<p>12月28日：大学数据库泄露，身份证信息泄露，更为敏感内容糟骇客泄露，泄露数据不详，只能靠截图揣摩!</p>
<p>以下为本次账号泄露情况的基本信息表：</p>
<p>CSDN共计泄露640万个帐号，泄漏信息：帐号、明文密码、电子邮件；</p>
<p>多玩：共计泄露800万个帐号，泄漏信息：帐号、MD5加密密码、部分明文密码，电子邮件，多玩昵称；</p>
<p>178.COM：共计泄露188万个账号，泄漏信息：帐号、MD5加密密码、全部明文密码、电子邮件、178昵称(178账户通用NGA)</p>
<p>天涯：共计泄露4000万个帐号(预计超过4000W数据)，泄漏信息：帐号、明文密码、电子邮件</p>
<p>人人网：共计泄露500万个帐号，泄漏信息：明文密码、电子邮件</p>
<p>UUU9.COM：共计泄露700万个帐号，泄漏信息：帐号、MD5加密密码、全部明文密码、电子邮件、U9昵称</p>
<p>网易土木在线：约4.3GB 137个文件，泄漏信息：帐号、MD5加密密码、其他相关数据</p>
<p>梦幻西游：约1.4G(木马盗取)，泄漏信息：帐号、邮箱、明文密码、角色名称、所在服务器、最后登陆时间、最后登陆IP。</p>
<p>北京麒麟网信息科技有限公司：共计泄露9072966个帐号，泄漏信息：帐户、明文密码</p>
<p>知名婚恋网站：共计泄露5261302个帐号，泄漏信息：帐户、明文密码</p>
<p>Ispeak.CN：共计泄露1680271个帐号，泄漏信息：帐户、明文密码、昵称</p>
<p>木蚂蚁：共计泄露13W帐号，泄漏信息：帐户、加密密码、数据库排序ID、其他信息</p>
<p>塞班论坛：共计泄露约140W帐号 泄漏信息：帐户、明文密码、电子邮箱</p>
<p>766.COM：共计泄露约12W帐号，泄漏信息：帐户、md5(md5(pwd).salt)密码、salt、电子邮箱、数据库排序ID</p>
<p>ys168：共计泄露约30W帐号，泄漏信息：帐户、明文、电子邮箱</p>
<p>当当：共计泄露约10W用户资料，泄漏信息：真实姓名、电子邮件、家庭住址、电话</p>
<p>凡客：共计泄露约20W用户资料，泄漏信息：真实姓名、电子邮件、家庭住址、电话</p>
<p>卓越：共计泄露约20W用户资料，泄漏信息：真实姓名、电子邮件、家庭住址、，电话</p>
<h3  class="related_post_title">随机文章</h3><ul class="related_post"><li>2011年08月21日 -- <a href="http://www.havenliu.com/android/648.html" title="设置Android系统程序的默认安装位置为SDCard">设置Android系统程序的默认安装位置为SDCard</a></li><li>2009年06月30日 -- <a href="http://www.havenliu.com/goodarticle/61.html" title="惠普前总裁孙振耀指点职业规划（一）">惠普前总裁孙振耀指点职业规划（一）</a></li><li>2010年09月7日 -- <a href="http://www.havenliu.com/bike/484.html" title="青海湖骑行之二">青海湖骑行之二</a></li><li>2010年07月11日 -- <a href="http://www.havenliu.com/mylife/465.html" title="西湖的荷花">西湖的荷花</a></li><li>2010年12月27日 -- <a href="http://www.havenliu.com/mylife/574.html" title="惭愧的一件事情">惭愧的一件事情</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.havenliu.com/goodarticle/688.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>悲剧的CSDN，狗日的金山，还有倒霉的我</title>
		<link>http://www.havenliu.com/mylife/678.html</link>
		<comments>http://www.havenliu.com/mylife/678.html#comments</comments>
		<pubDate>Thu, 22 Dec 2011 07:13:11 +0000</pubDate>
		<dc:creator>Haven</dc:creator>
				<category><![CDATA[生活杂记]]></category>

		<guid isPermaLink="false">http://www.havenliu.com/mylife/678.html</guid>
		<description><![CDATA[这两天睡觉老做噩梦，昨天下班路上车爆胎，就知道准没好事。果不其然。。。。。
早上一开电脑收到淘宝邮件，说我帐号有异常，给我锁了，当时我还骂淘宝，说我帐号能有什么异常，毕竟自己搞程序多年，对自己电脑的安全性还是比较有信心的。就没怎么在意，把帐号重新激活了。
后来看新闻，说SCDN用户数据库被狗日的金山员工泄漏，有500万用户资料被泄漏，我还幸灾乐祸的笑了，说金山这回有犯SB了。我也没在意。。。。
再后来，我登录不了CSDN，说密码错误，想想刚才看的新闻，估计自己也成了那500万中的一员【事后证实，自己确实就是那500万分之一】，我还是没在意，还和同事打趣说幸好我的CSDN帐号其他地方都不通用，黑客拿去也没用。就屁颠屁颠的把我CSDN帐号给重新激活了。
这时才想起我的淘宝帐号被封的事，一下傻眼了，连忙查了下我的淘宝登录记录：昨天【12月21号】有三次登录，IP分别为杭州，上海和成都，而昨天我更本就没用过淘宝。原来是我的淘宝帐号也被泄露了【淘宝帐号和CSDN帐号一样，邮箱也一样】，至此，我才发现事态的严重性，CSDN账户泄漏了我太多信息，很多社区帐号还有我的邮箱都不安全了。
其实早上还收到网易的邮件，提示我说我的CSDN账户可能泄漏，要我改邮箱密码，当时也被我不以为然的忽略了。。。。
最后，骂两句吧，发泄一下：狗日的金山，作为一个安全软件开发商，这点职业道德都没有，早点滚回你娘肚子里去吧，这社会不需要你们这样的人渣。这次泄漏事件不管是员工个人行为还是公司行为，金山都有不可推卸的责任。你们的员工怎么可以随便拿到这么重要的数据？还可以随便上传到迅雷快盘上去分享？你们这种企业就TM一社会的蛀虫！【更新一下：今天乘一时之快，写了前面这几句话，晚上回来觉得有点不妥。在事情还没弄清楚之前，或许我不该这样怪罪金山，毕竟现在说的数据是金山员工泄漏的也是从网上看来的，并没有官方的说法，所有下是把前面的话划下线吧。。。。最近火气比较大，容易走火！】
这种事情要是发生在国外不知道会怎样！
随机文章2009年08月3日 -- 如何知道你的身體正常了-来自传统中医2011年12月29日 -- 密码泄漏不完全总结2009年06月30日 -- 惠普前总裁孙振耀指点职业规划（一）2010年11月17日 -- 公司招了新人2011年01月15日 -- 经典语录:一个人的命运决定于晚上8点到10点之间]]></description>
			<content:encoded><![CDATA[<p>这两天睡觉老做噩梦，昨天下班路上车爆胎，就知道准没好事。果不其然。。。。。</p>
<p>早上一开电脑收到淘宝邮件，说我帐号有异常，给我锁了，当时我还骂淘宝，说我帐号能有什么异常，毕竟自己搞程序多年，对自己电脑的安全性还是比较有信心的。就没怎么在意，把帐号重新激活了。</p>
<p>后来看新闻，说SCDN用户数据库被狗日的金山员工泄漏，有500万用户资料被泄漏，我还幸灾乐祸的笑了，说金山这回有犯SB了。我也没在意。。。。</p>
<p>再后来，我登录不了CSDN，说密码错误，想想刚才看的新闻，估计自己也成了那500万中的一员【事后证实，自己确实就是那500万分之一】，我还是没在意，还和同事打趣说幸好我的CSDN帐号其他地方都不通用，黑客拿去也没用。就屁颠屁颠的把我CSDN帐号给重新激活了。</p>
<p>这时才想起我的淘宝帐号被封的事，一下傻眼了，连忙查了下我的淘宝登录记录：昨天【12月21号】有三次登录，IP分别为杭州，上海和成都，而昨天我更本就没用过淘宝。原来是我的淘宝帐号也被泄露了【淘宝帐号和CSDN帐号一样，邮箱也一样】，至此，我才发现事态的严重性，CSDN账户泄漏了我太多信息，很多社区帐号还有我的邮箱都不安全了。</p>
<p>其实早上还收到网易的邮件，提示我说我的CSDN账户可能泄漏，要我改邮箱密码，当时也被我不以为然的忽略了。。。。</p>
<p>最后，骂两句吧，发泄一下：<span style="text-decoration: line-through;">狗日的金山，作为一个安全软件开发商，这点职业道德都没有，早点滚回你娘肚子里去吧，这社会不需要你们这样的人渣。这次泄漏事件不管是员工个人行为还是公司行为，金山都有不可推卸的责任。你们的员工怎么可以随便拿到这么重要的数据？还可以随便上传到迅雷快盘上去分享？你们这种企业就TM一社会的蛀虫！</span>【<span style="color: #ff9900;">更新一下：今天乘一时之快，写了前面这几句话，晚上回来觉得有点不妥。在事情还没弄清楚之前，或许我不该这样怪罪金山，毕竟现在说的数据是金山员工泄漏的也是从网上看来的，并没有官方的说法，所有下是把前面的话划下线吧。。。。最近火气比较大，容易走火！</span>】</p>
<p>这种事情要是发生在国外不知道会怎样！</p>
<h3  class="related_post_title">随机文章</h3><ul class="related_post"><li>2011年03月18日 -- <a href="http://www.havenliu.com/mylife/621.html" title="昨天晚上超市买盐的笑话">昨天晚上超市买盐的笑话</a></li><li>2009年09月3日 -- <a href="http://www.havenliu.com/bike/219.html" title="【骑单车看世界】骑行徽杭古道（三）">【骑单车看世界】骑行徽杭古道（三）</a></li><li>2009年06月16日 -- <a href="http://www.havenliu.com/mylife/29.html" title="回家归来">回家归来</a></li><li>2010年06月2日 -- <a href="http://www.havenliu.com/other/448.html" title="用QQ的要注意了">用QQ的要注意了</a></li><li>2010年12月27日 -- <a href="http://www.havenliu.com/mylife/574.html" title="惭愧的一件事情">惭愧的一件事情</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.havenliu.com/mylife/678.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blog换服务器了</title>
		<link>http://www.havenliu.com/other/675.html</link>
		<comments>http://www.havenliu.com/other/675.html#comments</comments>
		<pubDate>Wed, 14 Dec 2011 08:35:51 +0000</pubDate>
		<dc:creator>Haven</dc:creator>
				<category><![CDATA[杂七杂八]]></category>

		<guid isPermaLink="false">http://www.havenliu.com/other/675.html</guid>
		<description><![CDATA[最近blog访问一直不太顺畅，前两天又换了一次，这次换了凤凰城的服务器，结果貌似没有太多改观，我现在还是要开VPN才能访问自己的Blog，比较悲剧。估计是成都这个地方的网络有关，whatever，也不想深究了,过段时间估计还会再买个性能更好的空间，到时候再搬一次家吧。这次搬家还把两个二级域名的数据搬掉了，不过我反正也不打算要了，回头把二级域名要升级为一级域名，重新再整个站【当然，不是Blog】。
就算这么麻烦，我也不想用国内的服务器，这狗日的Government，狗日的备案，你们都去见鬼吧。。。。呃，发两句牢骚应该不会被跨省吧。
随机文章2010年07月11日 -- 西湖的荷花2009年06月19日 -- 窗台的花枯了2009年06月6日 -- 我喜欢的十个禅宗故事2009年11月29日 -- MyEclipse 8没有启动画面的问题2011年01月15日 -- 经典语录:一个人的命运决定于晚上8点到10点之间]]></description>
			<content:encoded><![CDATA[<p>最近blog访问一直不太顺畅，前两天又换了一次，这次换了凤凰城的服务器，结果貌似没有太多改观，我现在还是要开VPN才能访问自己的Blog，比较悲剧。估计是成都这个地方的网络有关，whatever，也不想深究了,过段时间估计还会再买个性能更好的空间，到时候再搬一次家吧。这次搬家还把两个二级域名的数据搬掉了，不过我反正也不打算要了，回头把二级域名要升级为一级域名，重新再整个站【当然，不是Blog】。</p>
<p>就算这么麻烦，我也不想用国内的服务器，这狗日的Government，狗日的备案，你们都去见鬼吧。。。。呃，发两句牢骚应该不会被跨省吧。</p>
<h3  class="related_post_title">随机文章</h3><ul class="related_post"><li>2009年07月7日 -- <a href="http://www.havenliu.com/bike/131.html" title="2009年第96届环法自行车赛第四站视频">2009年第96届环法自行车赛第四站视频</a></li><li>2009年07月20日 -- <a href="http://www.havenliu.com/other/156.html" title="Picasa被和谐了">Picasa被和谐了</a></li><li>2009年09月24日 -- <a href="http://www.havenliu.com/mylife/250.html" title="垃圾评论要翻天了">垃圾评论要翻天了</a></li><li>2009年07月6日 -- <a href="http://www.havenliu.com/bike/115.html" title="2009年第96届环法自行车赛第二、三赛段视频">2009年第96届环法自行车赛第二、三赛段视频</a></li><li>2009年07月8日 -- <a href="http://www.havenliu.com/goodarticle/135.html" title="中国移动要推出的应用软件商店Mobile Market（简称MMarket）">中国移动要推出的应用软件商店Mobile Market（简称MMarket）</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.havenliu.com/other/675.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>让Android自带的Gallery实现多点缩放，拖动和边界回弹效果，效果流畅</title>
		<link>http://www.havenliu.com/android/668.html</link>
		<comments>http://www.havenliu.com/android/668.html#comments</comments>
		<pubDate>Sat, 10 Dec 2011 15:16:12 +0000</pubDate>
		<dc:creator>Haven</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.havenliu.com/?p=668</guid>
		<description><![CDATA[公司项目要开发一个Android看漫画的软件。看了效果，需要滑动翻页，多点缩放，拖动等。但看每个效果在android上实现都不难，但要全部组合在一起实现就比较麻烦，研究了两天，动手写了几个效果对比，最终还是选择了Gallery来做。但系统自带的Gallery组件不支持对点缩放和拖动【它默认的拖动是翻页，我需要的移动定位图片】，并且当快速滑动时，Gallery是多张连续翻页，而我只需要每次翻页一张。查了Android部分源码。觉得重新Gallery和ImageView来实现。结果还是比较理想的。性能还是不错的，无论是拖动、翻页还是对点缩放都非常流畅。把大致思路放出来共享下，抛砖引玉，如果大家有更好的改进方法，可以共同讨论。文章末尾有完整的Demo源代码，童鞋们看仔细了，就不要再给我留言或发邮件问我要源码了【PS：以前写的文章在末尾都放了源码，但估计很多人都没耐心完整的看完，就发邮件来问我要源码，搞的我屁股都洗白白了，准备上床睡觉，又打开电脑回Email】。

下面是重写的Gallery的代码。注释基本都写上了。
MyGallery.java:

?View Code JAVA/**
 * MyGallery.java
 * @version 1.0
 * @author Haven http://www.havenliu.com
 * @createTime 2011-12-9 下午03:42:53
 * android.widget.Gallery的子函数。此类很重要。建议仔细看
 */
package com.havenliu.demo;
&#160;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.widget.Gallery;
&#160;
public class MyGallery extends Gallery &#123;
	private GestureDetector gestureScanner;
	private MyImageView imageView;
&#160;
	public MyGallery&#40;Context context&#41; &#123;
		super&#40;context&#41;;
&#160;
	&#125;
&#160;
	public MyGallery&#40;Context context, AttributeSet attrs, int defStyle&#41; &#123;
		super&#40;context, attrs, defStyle&#41;;
	&#125;
&#160;
	public MyGallery&#40;Context context, AttributeSet attrs&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>公司项目要开发一个Android看漫画的软件。看了效果，需要滑动翻页，多点缩放，拖动等。但看每个效果在android上实现都不难，但要全部组合在一起实现就比较麻烦，研究了两天，动手写了几个效果对比，最终还是选择了Gallery来做。但系统自带的Gallery组件不支持对点缩放和拖动【它默认的拖动是翻页，我需要的移动定位图片】，并且当快速滑动时，Gallery是多张连续翻页，而我只需要每次翻页一张。查了Android部分源码。觉得重新Gallery和ImageView来实现。结果还是比较理想的。性能还是不错的，无论是拖动、翻页还是对点缩放都非常流畅。把大致思路放出来共享下，抛砖引玉，如果大家有更好的改进方法，可以共同讨论。文章末尾有完整的Demo源代码，童鞋们看仔细了，就不要再给我留言或发邮件问我要源码了<span style="color: #ff6600;">【PS：以前写的文章在末尾都放了源码，但估计很多人都没耐心完整的看完，就发邮件来问我要源码，搞的我屁股都洗白白了，准备上床睡觉，又打开电脑回Email】</span>。<br />
<span id="more-668"></span><br />
下面是重写的Gallery的代码。注释基本都写上了。<br />
MyGallery.java:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p668code3'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6683"><td class="code" id="p668code3"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * MyGallery.java
 * @version 1.0
 * @author Haven http://www.havenliu.com
 * @createTime 2011-12-9 下午03:42:53
 * android.widget.Gallery的子函数。此类很重要。建议仔细看
 */</span>
<span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.havenliu.demo</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.content.Context</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.graphics.Matrix</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.graphics.Rect</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.util.AttributeSet</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.util.Log</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.GestureDetector</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.MotionEvent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.View</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.GestureDetector.SimpleOnGestureListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.Gallery</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyGallery <span style="color: #000000; font-weight: bold;">extends</span> Gallery <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> GestureDetector gestureScanner<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> MyImageView imageView<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> MyGallery<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acontext+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Context</span></a> context<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> MyGallery<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acontext+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Context</span></a> context, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aattributeset+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">AttributeSet</span></a> attrs, <span style="color: #000066; font-weight: bold;">int</span> defStyle<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>context, attrs, defStyle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> MyGallery<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acontext+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Context</span></a> context, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aattributeset+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">AttributeSet</span></a> attrs<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>context, attrs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		gestureScanner <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GestureDetector<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> MySimpleGesture<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">setOnTouchListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> OnTouchListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #000066; font-weight: bold;">float</span> baseValue<span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">float</span> originalScale<span style="color: #339933;">;</span>
&nbsp;
			@Override
			<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onTouch<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aview+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">View</span></a> v, MotionEvent event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aview+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">View</span></a> view <span style="color: #339933;">=</span> MyGallery.<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getSelectedView</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>view <span style="color: #000000; font-weight: bold;">instanceof</span> MyImageView<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					imageView <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>MyImageView<span style="color: #009900;">&#41;</span> view<span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">getAction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> MotionEvent.<span style="color: #006633;">ACTION_DOWN</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						baseValue <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
						originalScale <span style="color: #339933;">=</span> imageView.<span style="color: #006633;">getScale</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">getAction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> MotionEvent.<span style="color: #006633;">ACTION_MOVE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">getPointerCount</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #000066; font-weight: bold;">float</span> x <span style="color: #339933;">=</span> event.<span style="color: #006633;">getX</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> event.<span style="color: #006633;">getX</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
							<span style="color: #000066; font-weight: bold;">float</span> y <span style="color: #339933;">=</span> event.<span style="color: #006633;">getY</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> event.<span style="color: #006633;">getY</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
							<span style="color: #000066; font-weight: bold;">float</span> value <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Amath+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Math</span></a>.<span style="color: #006633;">sqrt</span><span style="color: #009900;">&#40;</span>x <span style="color: #339933;">*</span> x <span style="color: #339933;">+</span> y <span style="color: #339933;">*</span> y<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// 计算两点的距离</span>
							<span style="color: #666666; font-style: italic;">// System.out.println(&quot;value:&quot; + value);</span>
							<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>baseValue <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
								baseValue <span style="color: #339933;">=</span> value<span style="color: #339933;">;</span>
							<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
								<span style="color: #000066; font-weight: bold;">float</span> scale <span style="color: #339933;">=</span> value <span style="color: #339933;">/</span> baseValue<span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// 当前两点间的距离除以手指落下时两点间的距离就是需要缩放的比例。</span>
								<span style="color: #666666; font-style: italic;">// scale the image</span>
								imageView.<span style="color: #006633;">zoomTo</span><span style="color: #009900;">&#40;</span>originalScale <span style="color: #339933;">*</span> scale, x <span style="color: #339933;">+</span> event.<span style="color: #006633;">getX</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>, y <span style="color: #339933;">+</span> event.<span style="color: #006633;">getY</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
							<span style="color: #009900;">&#125;</span>
						<span style="color: #009900;">&#125;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onScroll<span style="color: #009900;">&#40;</span>MotionEvent e1, MotionEvent e2, <span style="color: #000066; font-weight: bold;">float</span> distanceX, <span style="color: #000066; font-weight: bold;">float</span> distanceY<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aview+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">View</span></a> view <span style="color: #339933;">=</span> MyGallery.<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getSelectedView</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>view <span style="color: #000000; font-weight: bold;">instanceof</span> MyImageView<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			imageView <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>MyImageView<span style="color: #009900;">&#41;</span> view<span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000066; font-weight: bold;">float</span> v<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			Matrix m <span style="color: #339933;">=</span> imageView.<span style="color: #006633;">getImageMatrix</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			m.<span style="color: #006633;">getValues</span><span style="color: #009900;">&#40;</span>v<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// 图片实时的上下左右坐标</span>
			<span style="color: #000066; font-weight: bold;">float</span> left, right<span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// 图片的实时宽，高</span>
			<span style="color: #000066; font-weight: bold;">float</span> width, height<span style="color: #339933;">;</span>
			width <span style="color: #339933;">=</span> imageView.<span style="color: #006633;">getScale</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> imageView.<span style="color: #006633;">getImageWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			height <span style="color: #339933;">=</span> imageView.<span style="color: #006633;">getScale</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> imageView.<span style="color: #006633;">getImageHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// 一下逻辑为移动图片和滑动gallery换屏的逻辑。如果没对整个框架了解的非常清晰，改动以下的代码前请三思！！！！！！</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span> width <span style="color: #339933;">&lt;=</span> Main.<span style="color: #006633;">screenWidth</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span> height <span style="color: #339933;">&lt;=</span> Main.<span style="color: #006633;">screenHeight</span><span style="color: #009900;">&#41;</span><span style="color: #666666; font-style: italic;">// 如果图片当前大小&lt;屏幕大小，直接处理滑屏事件 			{ 				super.onScroll(e1, e2, distanceX, distanceY); 			} else { 				left = v[Matrix.MTRANS_X]; 				right = left + width; 				Rect r = new Rect(); 				imageView.getGlobalVisibleRect(r); 				if (distanceX &gt; 0)// 向左滑动</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>r.<span style="color: #006633;">left</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">// 判断当前ImageView是否显示完全</span>
						<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onScroll</span><span style="color: #009900;">&#40;</span>e1, e2, distanceX, distanceY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>right <span style="color: #339933;">&lt;</span> Main.<span style="color: #006633;">screenWidth</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onScroll</span><span style="color: #009900;">&#40;</span>e1, e2, distanceX, distanceY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
						imageView.<span style="color: #006633;">postTranslate</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>distanceX, <span style="color: #339933;">-</span>distanceY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>distanceX <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #666666; font-style: italic;">// 向右滑动</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>r.<span style="color: #006633;">right</span> <span style="color: #339933;">&lt;</span> Main.<span style="color: #006633;">screenWidth</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 						<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onScroll</span><span style="color: #009900;">&#40;</span>e1, e2, distanceX, distanceY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 					<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>left <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onScroll</span><span style="color: #009900;">&#40;</span>e1, e2, distanceX, distanceY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
						imageView.<span style="color: #006633;">postTranslate</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>distanceX, <span style="color: #339933;">-</span>distanceY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onScroll</span><span style="color: #009900;">&#40;</span>e1, e2, distanceX, distanceY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onFling<span style="color: #009900;">&#40;</span>MotionEvent e1, MotionEvent e2, <span style="color: #000066; font-weight: bold;">float</span> velocityX, <span style="color: #000066; font-weight: bold;">float</span> velocityY<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onTouchEvent<span style="color: #009900;">&#40;</span>MotionEvent event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		gestureScanner.<span style="color: #006633;">onTouchEvent</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">getAction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">case</span> MotionEvent.<span style="color: #006633;">ACTION_UP</span><span style="color: #339933;">:</span>
			<span style="color: #666666; font-style: italic;">// 判断上下边界是否越界</span>
			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aview+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">View</span></a> view <span style="color: #339933;">=</span> MyGallery.<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getSelectedView</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>view <span style="color: #000000; font-weight: bold;">instanceof</span> MyImageView<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				imageView <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>MyImageView<span style="color: #009900;">&#41;</span> view<span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">float</span> width <span style="color: #339933;">=</span> imageView.<span style="color: #006633;">getScale</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> imageView.<span style="color: #006633;">getImageWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">float</span> height <span style="color: #339933;">=</span> imageView.<span style="color: #006633;">getScale</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> imageView.<span style="color: #006633;">getImageHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span> width <span style="color: #339933;">&lt;=</span> Main.<span style="color: #006633;">screenWidth</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span> height <span style="color: #339933;">&lt;=</span> Main.<span style="color: #006633;">screenHeight</span><span style="color: #009900;">&#41;</span><span style="color: #666666; font-style: italic;">// 如果图片当前大小&lt;屏幕大小，判断边界 				{ 					break; 				} 				float v[] = new float[9]; 				Matrix m = imageView.getImageMatrix(); 				m.getValues(v); 				float top = v[Matrix.MTRANS_Y]; 				float bottom = top + height; 				if (top &gt; 0) {</span>
					imageView.<span style="color: #006633;">postTranslateDur</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>top, 200f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				Log.<span style="color: #006633;">i</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;manga&quot;</span>, <span style="color: #0000ff;">&quot;bottom:&quot;</span> <span style="color: #339933;">+</span> bottom<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>bottom <span style="color: #339933;">&lt;</span> Main.<span style="color: #006633;">screenHeight</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 					imageView.<span style="color: #006633;">postTranslateDur</span><span style="color: #009900;">&#40;</span>Main.<span style="color: #006633;">screenHeight</span> <span style="color: #339933;">-</span> bottom, 200f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 				<span style="color: #009900;">&#125;</span> 			<span style="color: #009900;">&#125;</span> 			<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span> 		<span style="color: #009900;">&#125;</span> 		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onTouchEvent</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 	<span style="color: #009900;">&#125;</span> 	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">class</span> MySimpleGesture <span style="color: #000000; font-weight: bold;">extends</span> SimpleOnGestureListener <span style="color: #009900;">&#123;</span> 		<span style="color: #666666; font-style: italic;">// 按两下的第二下Touch down时触发 		public boolean onDoubleTap(MotionEvent e) { 			View view = MyGallery.this.getSelectedView(); 			if (view instanceof MyImageView) { 				imageView = (MyImageView) view; 				if (imageView.getScale() &gt; imageView.getScaleRate()) {</span>
					imageView.<span style="color: #006633;">zoomTo</span><span style="color: #009900;">&#40;</span>imageView.<span style="color: #006633;">getScaleRate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, Main.<span style="color: #006633;">screenWidth</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span>, Main.<span style="color: #006633;">screenHeight</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span>, 200f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #666666; font-style: italic;">// imageView.layoutToCenter();</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
					imageView.<span style="color: #006633;">zoomTo</span><span style="color: #009900;">&#40;</span>1.0f, Main.<span style="color: #006633;">screenWidth</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span>, Main.<span style="color: #006633;">screenHeight</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span>, 200f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #009900;">&#125;</span>
			<span style="color: #666666; font-style: italic;">// return super.onDoubleTap(e);</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>MyImageView.java:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p668code4'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6684"><td class="code" id="p668code4"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * MyImageView.java
 * @version 1.0
 * @author Haven  http://www.havenliu.com
 * @createTime 2011-12-9 下午03:12:30
 * 此类代码是根据android系统自带的ImageViewTouchBase代码修改
 */</span>
<span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.havenliu.demo</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.content.Context</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.graphics.Bitmap</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.graphics.Matrix</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.graphics.RectF</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os.Handler</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.util.AttributeSet</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.KeyEvent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.ImageView</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyImageView <span style="color: #000000; font-weight: bold;">extends</span> ImageView <span style="color: #009900;">&#123;</span>
	@SuppressWarnings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;unused&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> TAG <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ImageViewTouchBase&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// This is the base transformation which is used to show the image</span>
	<span style="color: #666666; font-style: italic;">// initially. The current computation for this shows the image in</span>
	<span style="color: #666666; font-style: italic;">// it's entirety, letterboxing as needed. One could choose to</span>
	<span style="color: #666666; font-style: italic;">// show the image as cropped instead.</span>
	<span style="color: #666666; font-style: italic;">//</span>
	<span style="color: #666666; font-style: italic;">// This matrix is recomputed when we go from the thumbnail image to</span>
	<span style="color: #666666; font-style: italic;">// the full size image.</span>
	<span style="color: #000000; font-weight: bold;">protected</span> Matrix mBaseMatrix <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// This is the supplementary transformation which reflects what</span>
	<span style="color: #666666; font-style: italic;">// the user has done in terms of zooming and panning.</span>
	<span style="color: #666666; font-style: italic;">//</span>
	<span style="color: #666666; font-style: italic;">// This matrix remains the same when we go from the thumbnail image</span>
	<span style="color: #666666; font-style: italic;">// to the full size image.</span>
	<span style="color: #000000; font-weight: bold;">protected</span> Matrix mSuppMatrix <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// This is the final matrix which is computed as the concatentation</span>
	<span style="color: #666666; font-style: italic;">// of the base matrix and the supplementary matrix.</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> Matrix mDisplayMatrix <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Temporary buffer used for getting the values out of a matrix.</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> mMatrixValues <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// The current bitmap being displayed.</span>
	<span style="color: #666666; font-style: italic;">// protected final RotateBitmap mBitmapDisplayed = new RotateBitmap(null);</span>
	<span style="color: #000000; font-weight: bold;">protected</span> Bitmap image <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">int</span> mThisWidth <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span>, mThisHeight <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">float</span> mMaxZoom <span style="color: #339933;">=</span> 2.0f<span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// 最大缩放比例</span>
	<span style="color: #000066; font-weight: bold;">float</span> mMinZoom <span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// 最小缩放比例</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> imageWidth<span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// 图片的原始宽度</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> imageHeight<span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// 图片的原始高度</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">float</span> scaleRate<span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// 图片适应屏幕的缩放比例</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> MyImageView<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acontext+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Context</span></a> context, <span style="color: #000066; font-weight: bold;">int</span> imageWidth, <span style="color: #000066; font-weight: bold;">int</span> imageHeight<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">imageHeight</span> <span style="color: #339933;">=</span> imageHeight<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">imageWidth</span> <span style="color: #339933;">=</span> imageWidth<span style="color: #339933;">;</span>
		init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> MyImageView<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acontext+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Context</span></a> context, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aattributeset+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">AttributeSet</span></a> attrs, <span style="color: #000066; font-weight: bold;">int</span> imageWidth, <span style="color: #000066; font-weight: bold;">int</span> imageHeight<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>context, attrs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">imageHeight</span> <span style="color: #339933;">=</span> imageHeight<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">imageWidth</span> <span style="color: #339933;">=</span> imageWidth<span style="color: #339933;">;</span>
		init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * 计算图片要适应屏幕需要缩放的比例
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> arithScaleRate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">float</span> scaleWidth <span style="color: #339933;">=</span> Main.<span style="color: #006633;">screenWidth</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span> imageWidth<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">float</span> scaleHeight <span style="color: #339933;">=</span> Main.<span style="color: #006633;">screenHeight</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span> imageHeight<span style="color: #339933;">;</span>
		scaleRate <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Amath+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Math</span></a>.<span style="color: #006633;">min</span><span style="color: #009900;">&#40;</span>scaleWidth, scaleHeight<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">float</span> getScaleRate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> scaleRate<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> getImageWidth<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> imageWidth<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setImageWidth<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> imageWidth<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">imageWidth</span> <span style="color: #339933;">=</span> imageWidth<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> getImageHeight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> imageHeight<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setImageHeight<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> imageHeight<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">imageHeight</span> <span style="color: #339933;">=</span> imageHeight<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onKeyDown<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> keyCode, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Akeyevent+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">KeyEvent</span></a> event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>keyCode <span style="color: #339933;">==</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Akeyevent+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">KeyEvent</span></a>.<span style="color: #006633;">KEYCODE_BACK</span> <span style="color: #339933;">&amp;&amp;</span> event.<span style="color: #006633;">getRepeatCount</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			event.<span style="color: #006633;">startTracking</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onKeyDown</span><span style="color: #009900;">&#40;</span>keyCode, event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onKeyUp<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> keyCode, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Akeyevent+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">KeyEvent</span></a> event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>keyCode <span style="color: #339933;">==</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Akeyevent+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">KeyEvent</span></a>.<span style="color: #006633;">KEYCODE_BACK</span> <span style="color: #339933;">&amp;&amp;</span> event.<span style="color: #006633;">isTracking</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>event.<span style="color: #006633;">isCanceled</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>getScale<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> 1.0f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">// If we're zoomed in, pressing Back jumps out to show the</span>
				<span style="color: #666666; font-style: italic;">// entire image, otherwise Back returns the user to the gallery.</span>
				zoomTo<span style="color: #009900;">&#40;</span>1.0f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onKeyUp</span><span style="color: #009900;">&#40;</span>keyCode, event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> Handler mHandler <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Handler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setImageBitmap<span style="color: #009900;">&#40;</span>Bitmap bitmap<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">setImageBitmap</span><span style="color: #009900;">&#40;</span>bitmap<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		image <span style="color: #339933;">=</span> bitmap<span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// 计算适应屏幕的比例</span>
		arithScaleRate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//缩放到屏幕大小</span>
		zoomTo<span style="color: #009900;">&#40;</span>scaleRate,Main.<span style="color: #006633;">screenWidth</span> <span style="color: #339933;">/</span> 2f, Main.<span style="color: #006633;">screenHeight</span> <span style="color: #339933;">/</span> 2f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//居中</span>
		layoutToCenter<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//		imageView.zoomTo(scaleRate, Main.screenWidth / 2, Main.screenHeight / 2</span>
<span style="color: #666666; font-style: italic;">//		center(true, true);</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Center as much as possible in one or both axis. Centering is</span>
	<span style="color: #666666; font-style: italic;">// defined as follows: if the image is scaled down below the</span>
	<span style="color: #666666; font-style: italic;">// view's dimensions then center it (literally). If the image</span>
	<span style="color: #666666; font-style: italic;">// is scaled larger than the view and is translated out of view</span>
	<span style="color: #666666; font-style: italic;">// then translate it back into view (i.e. eliminate black bars).</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> center<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">boolean</span> horizontal, <span style="color: #000066; font-weight: bold;">boolean</span> vertical<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// if (mBitmapDisplayed.getBitmap() == null) {</span>
		<span style="color: #666666; font-style: italic;">// return;</span>
		<span style="color: #666666; font-style: italic;">// }</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>image <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		Matrix m <span style="color: #339933;">=</span> getImageViewMatrix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		RectF rect <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> RectF<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, image.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, image.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//		RectF rect = new RectF(0, 0, imageWidth*getScale(), imageHeight*getScale());</span>
&nbsp;
		m.<span style="color: #006633;">mapRect</span><span style="color: #009900;">&#40;</span>rect<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">float</span> height <span style="color: #339933;">=</span> rect.<span style="color: #006633;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">float</span> width <span style="color: #339933;">=</span> rect.<span style="color: #006633;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">float</span> deltaX <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span>, deltaY <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>vertical<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">int</span> viewHeight <span style="color: #339933;">=</span> getHeight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>height <span style="color: #339933;">&lt;</span> viewHeight<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 				deltaY <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>viewHeight <span style="color: #339933;">-</span> height<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">-</span> rect.<span style="color: #006633;">top</span><span style="color: #339933;">;</span> 			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>rect.<span style="color: #006633;">top</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				deltaY <span style="color: #339933;">=</span> <span style="color: #339933;">-</span>rect.<span style="color: #006633;">top</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>rect.<span style="color: #006633;">bottom</span> <span style="color: #339933;">&lt;</span> viewHeight<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				deltaY <span style="color: #339933;">=</span> getHeight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> rect.<span style="color: #006633;">bottom</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>horizontal<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">int</span> viewWidth <span style="color: #339933;">=</span> getWidth<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>width <span style="color: #339933;">&lt;</span> viewWidth<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 				deltaX <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>viewWidth <span style="color: #339933;">-</span> width<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">-</span> rect.<span style="color: #006633;">left</span><span style="color: #339933;">;</span> 			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>rect.<span style="color: #006633;">left</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				deltaX <span style="color: #339933;">=</span> <span style="color: #339933;">-</span>rect.<span style="color: #006633;">left</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>rect.<span style="color: #006633;">right</span> <span style="color: #339933;">&lt;</span> viewWidth<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 				deltaX <span style="color: #339933;">=</span> viewWidth <span style="color: #339933;">-</span> rect.<span style="color: #006633;">right</span><span style="color: #339933;">;</span> 			<span style="color: #009900;">&#125;</span> 		<span style="color: #009900;">&#125;</span> 		postTranslate<span style="color: #009900;">&#40;</span>deltaX, deltaY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 		setImageMatrix<span style="color: #009900;">&#40;</span>getImageViewMatrix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 	<span style="color: #009900;">&#125;</span> 	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 		setScaleType<span style="color: #009900;">&#40;</span>ImageView.<span style="color: #006633;">ScaleType</span>.<span style="color: #006633;">MATRIX</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 	<span style="color: #009900;">&#125;</span> 	<span style="color: #008000; font-style: italic; font-weight: bold;">/** 	 * 设置图片居中显示 	 */</span> 	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> layoutToCenter<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> 	<span style="color: #009900;">&#123;</span> 		<span style="color: #666666; font-style: italic;">//正在显示的图片实际宽高 		float width = imageWidth*getScale(); 		float height = imageHeight*getScale(); 		//空白区域宽高 		float fill_width = Main.screenWidth - width; 		float fill_height = Main.screenHeight - height; 		//需要移动的距离 		float tran_width = 0f; 		float tran_height = 0f; 		if(fill_width&gt;0)</span>
			tran_width <span style="color: #339933;">=</span> fill_width<span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>fill_height<span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
			tran_height <span style="color: #339933;">=</span> fill_height<span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
&nbsp;
		postTranslate<span style="color: #009900;">&#40;</span>tran_width, tran_height<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		setImageMatrix<span style="color: #009900;">&#40;</span>getImageViewMatrix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">float</span> getValue<span style="color: #009900;">&#40;</span>Matrix matrix, <span style="color: #000066; font-weight: bold;">int</span> whichValue<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		matrix.<span style="color: #006633;">getValues</span><span style="color: #009900;">&#40;</span>mMatrixValues<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		mMinZoom <span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span> Main.<span style="color: #006633;">screenWidth</span><span style="color: #339933;">/</span>2f<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>imageWidth<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> mMatrixValues<span style="color: #009900;">&#91;</span>whichValue<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Get the scale factor out of the matrix.</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">float</span> getScale<span style="color: #009900;">&#40;</span>Matrix matrix<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> getValue<span style="color: #009900;">&#40;</span>matrix, Matrix.<span style="color: #006633;">MSCALE_X</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">float</span> getScale<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> getScale<span style="color: #009900;">&#40;</span>mSuppMatrix<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Combine the base matrix and the supp matrix to make the final matrix.</span>
	<span style="color: #000000; font-weight: bold;">protected</span> Matrix getImageViewMatrix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// The final matrix is computed as the concatentation of the base matrix</span>
		<span style="color: #666666; font-style: italic;">// and the supplementary matrix.</span>
		mDisplayMatrix.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span>mBaseMatrix<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		mDisplayMatrix.<span style="color: #006633;">postConcat</span><span style="color: #009900;">&#40;</span>mSuppMatrix<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> mDisplayMatrix<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">float</span> SCALE_RATE <span style="color: #339933;">=</span> 1.25F<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Sets the maximum zoom, which is a scale relative to the base matrix. It</span>
	<span style="color: #666666; font-style: italic;">// is calculated to show the image at 400% zoom regardless of screen or</span>
	<span style="color: #666666; font-style: italic;">// image orientation. If in the future we decode the full 3 megapixel image,</span>
	<span style="color: #666666; font-style: italic;">// rather than the current 1024x768, this should be changed down to 200%.</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">float</span> maxZoom<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>image <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span> 1F<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">float</span> fw <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span> image.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span> mThisWidth<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">float</span> fh <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span> image.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span> mThisHeight<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">float</span> max <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Amath+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Math</span></a>.<span style="color: #006633;">max</span><span style="color: #009900;">&#40;</span>fw, fh<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> max<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> zoomTo<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span> scale, <span style="color: #000066; font-weight: bold;">float</span> centerX, <span style="color: #000066; font-weight: bold;">float</span> centerY<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>scale <span style="color: #339933;">&gt;</span> mMaxZoom<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			scale <span style="color: #339933;">=</span> mMaxZoom<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>scale <span style="color: #339933;">&lt;</span> mMinZoom<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			scale <span style="color: #339933;">=</span> mMinZoom<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">float</span> oldScale <span style="color: #339933;">=</span> getScale<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">float</span> deltaScale <span style="color: #339933;">=</span> scale <span style="color: #339933;">/</span> oldScale<span style="color: #339933;">;</span>
&nbsp;
		mSuppMatrix.<span style="color: #006633;">postScale</span><span style="color: #009900;">&#40;</span>deltaScale, deltaScale, centerX, centerY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		setImageMatrix<span style="color: #009900;">&#40;</span>getImageViewMatrix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		center<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> zoomTo<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">float</span> scale, <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">float</span> centerX, <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">float</span> centerY, <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">float</span> durationMs<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">float</span> incrementPerMs <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>scale <span style="color: #339933;">-</span> getScale<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> durationMs<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">float</span> oldScale <span style="color: #339933;">=</span> getScale<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span> startTime <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		mHandler.<span style="color: #006633;">post</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Arunnable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Runnable</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">long</span> now <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">float</span> currentMs <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Amath+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Math</span></a>.<span style="color: #006633;">min</span><span style="color: #009900;">&#40;</span>durationMs, now <span style="color: #339933;">-</span> startTime<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">float</span> target <span style="color: #339933;">=</span> oldScale <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>incrementPerMs <span style="color: #339933;">*</span> currentMs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				zoomTo<span style="color: #009900;">&#40;</span>target, centerX, centerY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>currentMs <span style="color: #339933;">&lt;</span> durationMs<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 					mHandler.<span style="color: #006633;">post</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 				<span style="color: #009900;">&#125;</span> 			<span style="color: #009900;">&#125;</span> 		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 	<span style="color: #009900;">&#125;</span> 	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> zoomTo<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span> scale<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 		<span style="color: #000066; font-weight: bold;">float</span> cx <span style="color: #339933;">=</span> getWidth<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> 2F<span style="color: #339933;">;</span> 		<span style="color: #000066; font-weight: bold;">float</span> cy <span style="color: #339933;">=</span> getHeight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> 2F<span style="color: #339933;">;</span> 		zoomTo<span style="color: #009900;">&#40;</span>scale, cx, cy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 	<span style="color: #009900;">&#125;</span> 	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> zoomToPoint<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span> scale, <span style="color: #000066; font-weight: bold;">float</span> pointX, <span style="color: #000066; font-weight: bold;">float</span> pointY<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 		<span style="color: #000066; font-weight: bold;">float</span> cx <span style="color: #339933;">=</span> getWidth<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> 2F<span style="color: #339933;">;</span> 		<span style="color: #000066; font-weight: bold;">float</span> cy <span style="color: #339933;">=</span> getHeight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> 2F<span style="color: #339933;">;</span> 		panBy<span style="color: #009900;">&#40;</span>cx <span style="color: #339933;">-</span> pointX, cy <span style="color: #339933;">-</span> pointY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 		zoomTo<span style="color: #009900;">&#40;</span>scale, cx, cy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 	<span style="color: #009900;">&#125;</span> 	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> zoomIn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 		zoomIn<span style="color: #009900;">&#40;</span>SCALE_RATE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 	<span style="color: #009900;">&#125;</span> 	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> zoomOut<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 		zoomOut<span style="color: #009900;">&#40;</span>SCALE_RATE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 	<span style="color: #009900;">&#125;</span> 	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> zoomIn<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span> rate<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>getScale<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;=</span> mMaxZoom<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Don't let the user zoom into the molecular level.</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>getScale<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;=</span> mMinZoom<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>image <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">float</span> cx <span style="color: #339933;">=</span> getWidth<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> 2F<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">float</span> cy <span style="color: #339933;">=</span> getHeight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> 2F<span style="color: #339933;">;</span>
&nbsp;
		mSuppMatrix.<span style="color: #006633;">postScale</span><span style="color: #009900;">&#40;</span>rate, rate, cx, cy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		setImageMatrix<span style="color: #009900;">&#40;</span>getImageViewMatrix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> zoomOut<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span> rate<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>image <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">float</span> cx <span style="color: #339933;">=</span> getWidth<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> 2F<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">float</span> cy <span style="color: #339933;">=</span> getHeight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> 2F<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Zoom out to at most 1x.</span>
		Matrix tmp <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #009900;">&#40;</span>mSuppMatrix<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		tmp.<span style="color: #006633;">postScale</span><span style="color: #009900;">&#40;</span>1F <span style="color: #339933;">/</span> rate, 1F <span style="color: #339933;">/</span> rate, cx, cy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>getScale<span style="color: #009900;">&#40;</span>tmp<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> 1F<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			mSuppMatrix.<span style="color: #006633;">setScale</span><span style="color: #009900;">&#40;</span>1F, 1F, cx, cy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			mSuppMatrix.<span style="color: #006633;">postScale</span><span style="color: #009900;">&#40;</span>1F <span style="color: #339933;">/</span> rate, 1F <span style="color: #339933;">/</span> rate, cx, cy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		setImageMatrix<span style="color: #009900;">&#40;</span>getImageViewMatrix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		center<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> postTranslate<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span> dx, <span style="color: #000066; font-weight: bold;">float</span> dy<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		mSuppMatrix.<span style="color: #006633;">postTranslate</span><span style="color: #009900;">&#40;</span>dx, dy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		setImageMatrix<span style="color: #009900;">&#40;</span>getImageViewMatrix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">float</span> _dy<span style="color: #339933;">=</span>0.0f<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> postTranslateDur<span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">float</span> dy, <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">float</span> durationMs<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		_dy<span style="color: #339933;">=</span>0.0f<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">float</span> incrementPerMs <span style="color: #339933;">=</span> dy <span style="color: #339933;">/</span> durationMs<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span> startTime <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		mHandler.<span style="color: #006633;">post</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Arunnable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Runnable</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">long</span> now <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">float</span> currentMs <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Amath+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Math</span></a>.<span style="color: #006633;">min</span><span style="color: #009900;">&#40;</span>durationMs, now <span style="color: #339933;">-</span> startTime<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				postTranslate<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, incrementPerMs<span style="color: #339933;">*</span>currentMs<span style="color: #339933;">-</span>_dy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				_dy<span style="color: #339933;">=</span>incrementPerMs<span style="color: #339933;">*</span>currentMs<span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>currentMs <span style="color: #339933;">&lt;</span> durationMs<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					mHandler.<span style="color: #006633;">post</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> panBy<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span> dx, <span style="color: #000066; font-weight: bold;">float</span> dy<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		postTranslate<span style="color: #009900;">&#40;</span>dx, dy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		setImageMatrix<span style="color: #009900;">&#40;</span>getImageViewMatrix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>PS：这只是个Demo，代码有些地方组织可能比较混乱，重要的是实现方法。如果你对这种实现方法有更好的建议或改进，可以留言，我会第一时间回复。</p>
<p>源码：<a href="http://www.havenliu.com/download/undelete/GalleryDemo.zip">狂击这里</a></p>
<p>转载请务必注明出处。谢谢</p>
<p>扯点题外话：最近好懒，发现好久都没更新Blog了。办公室来了个老外，大家都疯狂的跟着她学英语，我也想学啊，可想想读书时我英语的悲惨历史，就一点自信都没有了。唉</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2011年09月8日 -- <a href="http://www.havenliu.com/android/652.html" title="没装显卡驱动，开发cocos2d&mdash;x的问题">没装显卡驱动，开发cocos2d&mdash;x的问题</a></li><li>2011年08月21日 -- <a href="http://www.havenliu.com/android/648.html" title="设置Android系统程序的默认安装位置为SDCard">设置Android系统程序的默认安装位置为SDCard</a></li><li>2011年06月19日 -- <a href="http://www.havenliu.com/android/631.html" title="Android面试题（一）">Android面试题（一）</a></li><li>2011年01月7日 -- <a href="http://www.havenliu.com/android/598.html" title="【火车票验证精灵】完成了">【火车票验证精灵】完成了</a></li><li>2010年12月31日 -- <a href="http://www.havenliu.com/mylife/580.html" title="&#8220;短信助手&#8221;正式开放下载">&#8220;短信助手&#8221;正式开放下载</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.havenliu.com/android/668.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>发现个不错的网盘：酷盘</title>
		<link>http://www.havenliu.com/other/666.html</link>
		<comments>http://www.havenliu.com/other/666.html#comments</comments>
		<pubDate>Fri, 09 Dec 2011 08:06:57 +0000</pubDate>
		<dc:creator>Haven</dc:creator>
				<category><![CDATA[杂七杂八]]></category>

		<guid isPermaLink="false">http://www.havenliu.com/other/666.html</guid>
		<description><![CDATA[前几天逛VeryCD的时候，找了几个资源一直下载不下来，后来发现这资源后面有个红色的箭头，点了一下，发现是直接转存到酷盘，就试了一下，存到酷盘里再下载，速度居然有200-300K，最快的时候冲到500K，简直乐坏我了。我4.5G的资源下了一个星期才50%。转存到酷盘几个小时就搞定。
酷盘还有个好处，就是可以几台电脑同步文件。这个就和Evernote的同步一样，用过Evernote的童鞋应该都知道，还可以同步带Android手机【我爱死这点了，意味着可以带着手机就能带上所有的数据在任何地方访问】。本来是一直在找SVN服务器。这样就可以在家里和公司同时进行开发，但免费的基本没符合我要求的，有段时间天天用U盘拷，现在发现用酷盘貌似可以当SVN服务器使用，直接把工程文件夹放到酷盘目录下面。一边coding，一边就自动同步了。相当方便，唯一不足的是没有回退功能。但这样已经很不错了。
呃。。。搞的我像个枪手一样的。向毛主席保证我绝对不是枪手，也不是啥五毛党。要注册的狂击这里吧。
随机文章2010年07月11日 -- 西湖的荷花2009年07月20日 -- Picasa被和谐了2010年12月22日 -- 一个关于楼市的冷笑话2010年01月5日 -- 给大家讲一个暴力拆迁未遂的故事2009年06月30日 -- 惠普前总裁孙振耀指点职业规划（三）]]></description>
			<content:encoded><![CDATA[<p>前几天逛VeryCD的时候，找了几个资源一直下载不下来，后来发现这资源后面有个红色的箭头，点了一下，发现是直接转存到酷盘，就试了一下，存到酷盘里再下载，速度居然有200-300K，最快的时候冲到500K，简直乐坏我了。我4.5G的资源下了一个星期才50%。转存到酷盘几个小时就搞定。</p>
<p>酷盘还有个好处，就是可以几台电脑同步文件。这个就和Evernote的同步一样，用过Evernote的童鞋应该都知道，还可以同步带Android手机【我爱死这点了，意味着可以带着手机就能带上所有的数据在任何地方访问】。本来是一直在找SVN服务器。这样就可以在家里和公司同时进行开发，但免费的基本没符合我要求的，有段时间天天用U盘拷，现在发现用酷盘貌似可以当SVN服务器使用，直接把工程文件夹放到酷盘目录下面。一边coding，一边就自动同步了。相当方便，唯一不足的是没有回退功能。但这样已经很不错了。</p>
<p>呃。。。搞的我像个枪手一样的。向毛主席保证我绝对不是枪手，也不是啥五毛党。要注册的狂击<a href="http://kb.vc/bVhy">这里</a>吧。</p>
<h3  class="related_post_title">随机文章</h3><ul class="related_post"><li>2010年04月8日 -- <a href="http://www.havenliu.com/goodarticle/359.html" title="转摘一篇关于目前房价的文章">转摘一篇关于目前房价的文章</a></li><li>2009年08月3日 -- <a href="http://www.havenliu.com/mylife/176.html" title="如何知道你的身體正常了-来自传统中医">如何知道你的身體正常了-来自传统中医</a></li><li>2011年02月22日 -- <a href="http://www.havenliu.com/goodarticle/616.html" title="江城子">江城子</a></li><li>2009年07月7日 -- <a href="http://www.havenliu.com/mylife/119.html" title="回家听来的真实故事">回家听来的真实故事</a></li><li>2010年08月19日 -- <a href="http://www.havenliu.com/bike/472.html" title="青海湖骑行">青海湖骑行</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.havenliu.com/other/666.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>感冒了</title>
		<link>http://www.havenliu.com/mylife/664.html</link>
		<comments>http://www.havenliu.com/mylife/664.html#comments</comments>
		<pubDate>Fri, 04 Nov 2011 12:27:33 +0000</pubDate>
		<dc:creator>Haven</dc:creator>
				<category><![CDATA[生活杂记]]></category>

		<guid isPermaLink="false">http://www.havenliu.com/mylife/664.html</guid>
		<description><![CDATA[最终还是没能扛住，下午请了半天假去医院挂点滴，医生说我这比较严重，要连续打三天，我一听心都凉大半截，一个感冒都要打三天点滴，是我身体抵抗力太差？还是现在的医术倒退了？怀念小时候，去村的医生那里，配几包五颜六色的小药丸，几毛钱就可以搞定。
下午躺在不怎么干净的病床上，突然觉得好幸福，总算不用想我的代码要如何优化，Bug是怎么产生的，也不用为工作进度而烦恼，不用为生活和家庭的琐事而歇斯底里。虽然裹着厚厚的衣服，也仍然能感觉到那窄窄的病床的温暖。
这段时间工作强度或许有点大，几次在上班的路上因考虑一天的工作也骑错路，还有两个Bug的解决方法是在马桶上想出来的，但好在项目总算如期发布了，现在新的项目已经下来，期待新的突破。
随机文章2011年03月18日 -- 昨天晚上超市买盐的笑话2011年12月9日 -- 发现个不错的网盘：酷盘2009年11月29日 -- MyEclipse 8没有启动画面的问题2010年05月11日 -- 找到一份比较全面的freemarker语法总结2011年02月17日 -- 【网摘】6岁女童每天捉虫捡米粒养鸡以攒钱交学费]]></description>
			<content:encoded><![CDATA[<p>最终还是没能扛住，下午请了半天假去医院挂点滴，医生说我这比较严重，要连续打三天，我一听心都凉大半截，一个感冒都要打三天点滴，是我身体抵抗力太差？还是现在的医术倒退了？怀念小时候，去村的医生那里，配几包五颜六色的小药丸，几毛钱就可以搞定。</p>
<p>下午躺在不怎么干净的病床上，突然觉得好幸福，总算不用想我的代码要如何优化，Bug是怎么产生的，也不用为工作进度而烦恼，不用为生活和家庭的琐事而歇斯底里。虽然裹着厚厚的衣服，也仍然能感觉到那窄窄的病床的温暖。</p>
<p>这段时间工作强度或许有点大，几次在上班的路上因考虑一天的工作也骑错路，还有两个Bug的解决方法是在马桶上想出来的，但好在项目总算如期发布了，现在新的项目已经下来，期待新的突破。</p>
<h3  class="related_post_title">随机文章</h3><ul class="related_post"><li>2011年12月10日 -- <a href="http://www.havenliu.com/android/668.html" title="让Android自带的Gallery实现多点缩放，拖动和边界回弹效果，效果流畅">让Android自带的Gallery实现多点缩放，拖动和边界回弹效果，效果流畅</a></li><li>2009年06月2日 -- <a href="http://www.havenliu.com/goodarticle/19.html" title="水煮互联网创业，互联网创业的盲区">水煮互联网创业，互联网创业的盲区</a></li><li>2010年05月15日 -- <a href="http://www.havenliu.com/bike/423.html" title="江南古镇之【骑行南浔】">江南古镇之【骑行南浔】</a></li><li>2010年02月24日 -- <a href="http://www.havenliu.com/mylife/305.html" title="朋友的事">朋友的事</a></li><li>2010年08月26日 -- <a href="http://www.havenliu.com/goodarticle/481.html" title="爆笑三国之张飞流水账">爆笑三国之张飞流水账</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.havenliu.com/mylife/664.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>cocos2d-x中，CCSAXParser的一个小问题</title>
		<link>http://www.havenliu.com/android/656.html</link>
		<comments>http://www.havenliu.com/android/656.html#comments</comments>
		<pubDate>Sun, 09 Oct 2011 14:04:13 +0000</pubDate>
		<dc:creator>Haven</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[cocos2d-x]]></category>

		<guid isPermaLink="false">http://www.havenliu.com/?p=656</guid>
		<description><![CDATA[我觉得这可能是一个Bug，但拿不太准，上次在这里 乱说cocos2d-x没有API，事后Walzer解释说是我没找对地方，有了前车之鉴，现在说话得小心了。废话少说，言归正传：
今天用CCSAXParser解析xml文件，编译通不过，报link异常：
2&#62;XMLParser.obj : error LNK2019: 无法解析的外部符号 &#8220;public: __thiscall cocos2d::CCSAXParser::~CCSAXParser(void)&#8221; (??1CCSAXParser@cocos2d@@QAE@XZ)，该符号在函数 &#8220;public: bool __thiscall XMLParser::parserFile(char const *)&#8221; (?parserFile@XMLParser@@QAE_NPBD@Z) 中被引用
2&#62;XMLParser.obj : error LNK2019: 无法解析的外部符号 &#8220;public: bool __thiscall cocos2d::CCSAXParser::parse(char const *)&#8221; (?parse@CCSAXParser@cocos2d@@QAE_NPBD@Z)，该符号在函数 &#8220;public: bool __thiscall XMLParser::parserFile(char const *)&#8221; (?parserFile@XMLParser@@QAE_NPBD@Z) 中被引用
2&#62;XMLParser.obj : error LNK2019: 无法解析的外部符号 &#8220;public: void __thiscall cocos2d::CCSAXParser::setDelegator(class cocos2d::CCSAXDelegator *)&#8221; (?setDelegator@CCSAXParser@cocos2d@@QAEXPAVCCSAXDelegator@2@@Z)，该符号在函数 &#8220;public: bool __thiscall XMLParser::parserFile(char const *)&#8221; (?parserFile@XMLParser@@QAE_NPBD@Z) [...]]]></description>
			<content:encoded><![CDATA[<p>我觉得这可能是一个Bug，但拿不太准，上次在<a href="http://www.havenliu.com/android/652.html">这里</a> 乱说cocos2d-x没有API，事后Walzer解释说是我没找对地方，有了前车之鉴，现在说话得小心了。废话少说，言归正传：</p>
<p>今天用CCSAXParser解析xml文件，编译通不过，报link异常：<br />
2&gt;XMLParser.obj : error LNK2019: 无法解析的外部符号 &#8220;public: __thiscall cocos2d::CCSAXParser::~CCSAXParser(void)&#8221; (??1CCSAXParser@cocos2d@@QAE@XZ)，该符号在函数 &#8220;public: bool __thiscall XMLParser::parserFile(char const *)&#8221; (?parserFile@XMLParser@@QAE_NPBD@Z) 中被引用<br />
2&gt;XMLParser.obj : error LNK2019: 无法解析的外部符号 &#8220;public: bool __thiscall cocos2d::CCSAXParser::parse(char const *)&#8221; (?parse@CCSAXParser@cocos2d@@QAE_NPBD@Z)，该符号在函数 &#8220;public: bool __thiscall XMLParser::parserFile(char const *)&#8221; (?parserFile@XMLParser@@QAE_NPBD@Z) 中被引用<br />
2&gt;XMLParser.obj : error LNK2019: 无法解析的外部符号 &#8220;public: void __thiscall cocos2d::CCSAXParser::setDelegator(class cocos2d::CCSAXDelegator *)&#8221; (?setDelegator@CCSAXParser@cocos2d@@QAEXPAVCCSAXDelegator@2@@Z)，该符号在函数 &#8220;public: bool __thiscall XMLParser::parserFile(char const *)&#8221; (?parserFile@XMLParser@@QAE_NPBD@Z) 中被引用<br />
2&gt;XMLParser.obj : error LNK2019: 无法解析的外部符号 &#8220;public: bool __thiscall cocos2d::CCSAXParser::init(char const *)&#8221; (?init@CCSAXParser@cocos2d@@QAE_NPBD@Z)，该符号在函数 &#8220;public: bool __thiscall XMLParser::parserFile(char const *)&#8221; (?parserFile@XMLParser@@QAE_NPBD@Z) 中被引用</p>
<p>仔细检查了代码，没看出什么异常来。后来检查cocos2d-x的源文件。发现是CCSAXParser的定义中没有加CC_DLL,只要把CCSAXParser.h文件中的class CCSAXParser。。。。修改为class CC_DLL CCSAXParser即可正常编译和运行。</p>
<p>至于原因我就不说了，免得像我这种半斤八两的人说出来又贻笑大方了。</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2011年09月8日 -- <a href="http://www.havenliu.com/android/652.html" title="没装显卡驱动，开发cocos2d&mdash;x的问题">没装显卡驱动，开发cocos2d&mdash;x的问题</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.havenliu.com/android/656.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>闲话微博</title>
		<link>http://www.havenliu.com/other/653.html</link>
		<comments>http://www.havenliu.com/other/653.html#comments</comments>
		<pubDate>Wed, 21 Sep 2011 14:10:15 +0000</pubDate>
		<dc:creator>Haven</dc:creator>
				<category><![CDATA[杂七杂八]]></category>

		<guid isPermaLink="false">http://www.havenliu.com/other/653.html</guid>
		<description><![CDATA[微博确实是个好东西，作为你一个80后或90后，你还不了解什么是微博，你可能失去了了解这个世界的一个重要通道，你可能不会知道苍井空的英语有多烂，也可能不知道郭美美有多有钱，甚至不知道你的那个他（她）昨天吃了碗什么面。但是看着很多人每天为了关注或被关注，如痴如醉的在微博上浪费着自己的时间的时候，我有些迷茫了。
如果你只是一个普通的老百姓，每天等着下班，等着发工资，无论你关注多少人或被多少人关注，也不会为你的生活带来多少物质上的改善。最多也只是在和朋友的闲谈调侃加点新鲜话题，可能你一直没注意到，你那些用了很多时间关注来的新闻，其实大家转瞬即忘。
对于个人生活而言，微博就是将个人的生活赤裸裸的展示给别人，如果你不是郭美美，其实你的生活里并没有那么多值得你炫耀的东西，你生活里的喜怒哀乐仅仅付诸于别人的笑谈中。
如果你每天上班时间还念念不忘自己的微博，时不时偷偷点出来看一下，如果你在走路或吃饭的时候，两眼的焦点还在手机上，如果你在和朋友的交谈中总忍不住会自豪的说我关注了谁、谁关注了我、有多少人关注了我。。。。。。你应该认真思考一下，微博是否占据你太多的时间。
随机文章2011年10月9日 -- cocos2d-x中，CCSAXParser的一个小问题2009年07月12日 -- 2009年第96届环法自行车赛第七、八站视频2011年09月8日 -- 没装显卡驱动，开发cocos2d&#8212;x的问题2010年09月23日 -- 换了个手机2009年07月7日 -- 回家听来的真实故事]]></description>
			<content:encoded><![CDATA[<p>微博确实是个好东西，作为你一个80后或90后，你还不了解什么是微博，你可能失去了了解这个世界的一个重要通道，你可能不会知道苍井空的英语有多烂，也可能不知道郭美美有多有钱，甚至不知道你的那个他（她）昨天吃了碗什么面。但是看着很多人每天为了关注或被关注，如痴如醉的在微博上浪费着自己的时间的时候，我有些迷茫了。</p>
<p>如果你只是一个普通的老百姓，每天等着下班，等着发工资，无论你关注多少人或被多少人关注，也不会为你的生活带来多少物质上的改善。最多也只是在和朋友的闲谈调侃加点新鲜话题，可能你一直没注意到，你那些用了很多时间关注来的新闻，其实大家转瞬即忘。</p>
<p>对于个人生活而言，微博就是将个人的生活赤裸裸的展示给别人，如果你不是郭美美，其实你的生活里并没有那么多值得你炫耀的东西，你生活里的喜怒哀乐仅仅付诸于别人的笑谈中。</p>
<p>如果你每天上班时间还念念不忘自己的微博，时不时偷偷点出来看一下，如果你在走路或吃饭的时候，两眼的焦点还在手机上，如果你在和朋友的交谈中总忍不住会自豪的说我关注了谁、谁关注了我、有多少人关注了我。。。。。。你应该认真思考一下，微博是否占据你太多的时间。</p>
<h3  class="related_post_title">随机文章</h3><ul class="related_post"><li>2010年10月21日 -- <a href="http://www.havenliu.com/java/511.html" title="XML文件编辑和格式化的利器：Firstobject free XML editor ">XML文件编辑和格式化的利器：Firstobject free XML editor </a></li><li>2009年07月8日 -- <a href="http://www.havenliu.com/goodarticle/135.html" title="中国移动要推出的应用软件商店Mobile Market（简称MMarket）">中国移动要推出的应用软件商店Mobile Market（简称MMarket）</a></li><li>2009年07月7日 -- <a href="http://www.havenliu.com/mylife/119.html" title="回家听来的真实故事">回家听来的真实故事</a></li><li>2010年05月15日 -- <a href="http://www.havenliu.com/bike/423.html" title="江南古镇之【骑行南浔】">江南古镇之【骑行南浔】</a></li><li>2010年05月6日 -- <a href="http://www.havenliu.com/mylife/409.html" title="西塘游记">西塘游记</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.havenliu.com/other/653.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>没装显卡驱动，开发cocos2d&#8212;x的问题</title>
		<link>http://www.havenliu.com/android/652.html</link>
		<comments>http://www.havenliu.com/android/652.html#comments</comments>
		<pubDate>Thu, 08 Sep 2011 13:16:34 +0000</pubDate>
		<dc:creator>Haven</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[cocos2d-x]]></category>

		<guid isPermaLink="false">http://www.havenliu.com/android/652.html</guid>
		<description><![CDATA[为了满足跨平台的需求，公司决定用cocos2d-x引擎来开发所有Android平台游戏，对于我这个抱着java从娘肚子里出生的来说，意味着要重新学c/c++，而且cocos2d-x作为一个较新的引擎，研究和使用的人很少，文档资料少的可怜，连最起码的API都没份完整的，每天我孤独的啃着生硬的cocos2d-x，寂寞的内牛满面啦。。。。。
不过还好coco2d-x基本是完整的移植coco2d-iphone，所以如果你熟悉coco2d-iphone的话，coco2d-x基本也就没什么问题，如果你连coco2d-iphone也不熟【就像悲剧的我一样】，其实也不要怕，至少你还熟悉c++吧，如果你连c++也不懂，呃。。。。那我们就可以握手了。
刚开始运行自己写的cocos2d-x Demo的时候出了个很奇怪的错误：
PVR: VFrame attempted to use one of this functions
PVR: wglChoosePixelFormatARB
PVR: but they are not present on your machine

折腾了好久，才发现原来是公司的电脑都没装显卡驱动，只要装下最新的驱动就好了，那一刻真想爆了IT部门的菊花，装系统也太偷懒了。
再磨叽几句，cocos2d-X没有完整的API，这个你可以直接用cocos2d-iphone的API，类名和函数名基本一样，一般使用都没问题。还有cocos2d-x还不是一个很成熟的引擎，掉帧现象比较严重，性能方面表现也一般，且根据官方的说法，需要在Android 2.2上才能满性能发挥，但如果你不是做特别大型和复杂的游戏，其实完全没问题，毕竟现在cocos2d-x已经出来很多很不错的游戏，比如现在很火的“捕鱼达人”。另外国内还有一款和cocos2d-x很类似的引擎，叫“微云”，也是用c++开发的，性能上没做深入测试，掉帧现象基本没有，实例比较丰富，代码封装度比较高，但不开源。cocos2d-x也是国人做的，可官方的所有说明和文档基本是英文，这点有点让人不爽。cocos2d-x和微云在国内某知名的Android论坛还有过口水之争，甚至牵扯出双方身世之类，其实我觉得做技术的人应该比较淡定才对，英雄不问出处，做好自己的产品才是最重要的。
相关文章2011年12月10日 -- 让Android自带的Gallery实现多点缩放，拖动和边界回弹效果，效果流畅2011年10月9日 -- cocos2d-x中，CCSAXParser的一个小问题2011年08月21日 -- 设置Android系统程序的默认安装位置为SDCard2011年06月19日 -- Android面试题（一）2011年01月7日 -- 【火车票验证精灵】完成了]]></description>
			<content:encoded><![CDATA[<p>为了满足跨平台的需求，公司决定用cocos2d-x引擎来开发所有Android平台游戏，对于我这个抱着java从娘肚子里出生的来说，意味着要重新学c/c++，而且cocos2d-x作为一个较新的引擎，研究和使用的人很少，文档资料少的可怜，连最起码的API都没份完整的，每天我孤独的啃着生硬的cocos2d-x，寂寞的内牛满面啦。。。。。</p>
<p>不过还好coco2d-x基本是完整的移植coco2d-iphone，所以如果你熟悉coco2d-iphone的话，coco2d-x基本也就没什么问题，如果你连coco2d-iphone也不熟【就像悲剧的我一样】，其实也不要怕，至少你还熟悉c++吧，如果你连c++也不懂，呃。。。。那我们就可以握手了。</p>
<p>刚开始运行自己写的cocos2d-x Demo的时候出了个很奇怪的错误：<br />
PVR: VFrame attempted to use one of this functions<br />
PVR: wglChoosePixelFormatARB<br />
PVR: but they are not present on your machine</p>
<p><a rel="lightbox" href="http://www.havenliu.com/wp-content/uploads/2011/09/Image.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 5px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image" src="http://www.havenliu.com/wp-content/uploads/2011/09/Image_thumb.png" border="0" alt="Image" width="442" height="266" /></a></p>
<p>折腾了好久，才发现原来是公司的电脑都没装显卡驱动，只要装下最新的驱动就好了，那一刻真想爆了IT部门的菊花，装系统也太偷懒了。</p>
<p>再磨叽几句，cocos2d-X没有完整的API，这个你可以直接用cocos2d-iphone的API，类名和函数名基本一样，一般使用都没问题。还有cocos2d-x还不是一个很成熟的引擎，掉帧现象比较严重，性能方面表现也一般，且根据官方的说法，需要在Android 2.2上才能满性能发挥，但如果你不是做特别大型和复杂的游戏，其实完全没问题，毕竟现在cocos2d-x已经出来很多很不错的游戏，比如现在很火的“捕鱼达人”。另外国内还有一款和cocos2d-x很类似的引擎，叫“微云”，也是用c++开发的，性能上没做深入测试，掉帧现象基本没有，实例比较丰富，代码封装度比较高，但不开源。cocos2d-x也是国人做的，可官方的所有说明和文档基本是英文，这点有点让人不爽。cocos2d-x和微云在国内某知名的Android论坛还有过口水之争，甚至牵扯出双方身世之类，其实我觉得做技术的人应该比较淡定才对，英雄不问出处，做好自己的产品才是最重要的。</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2011年12月10日 -- <a href="http://www.havenliu.com/android/668.html" title="让Android自带的Gallery实现多点缩放，拖动和边界回弹效果，效果流畅">让Android自带的Gallery实现多点缩放，拖动和边界回弹效果，效果流畅</a></li><li>2011年10月9日 -- <a href="http://www.havenliu.com/android/656.html" title="cocos2d-x中，CCSAXParser的一个小问题">cocos2d-x中，CCSAXParser的一个小问题</a></li><li>2011年08月21日 -- <a href="http://www.havenliu.com/android/648.html" title="设置Android系统程序的默认安装位置为SDCard">设置Android系统程序的默认安装位置为SDCard</a></li><li>2011年06月19日 -- <a href="http://www.havenliu.com/android/631.html" title="Android面试题（一）">Android面试题（一）</a></li><li>2011年01月7日 -- <a href="http://www.havenliu.com/android/598.html" title="【火车票验证精灵】完成了">【火车票验证精灵】完成了</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.havenliu.com/android/652.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>设置Android系统程序的默认安装位置为SDCard</title>
		<link>http://www.havenliu.com/android/648.html</link>
		<comments>http://www.havenliu.com/android/648.html#comments</comments>
		<pubDate>Sun, 21 Aug 2011 14:57:08 +0000</pubDate>
		<dc:creator>Haven</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.havenliu.com/android/648.html</guid>
		<description><![CDATA[最近手机抽风，突然没信号或者信号很差，开始还以为是移动的问题，后来才知道自己错怪了10086。不得已只能刷机，把系统从2.1升到了2.2.1，原本以为升到了2.2就可以告别因装软件太多，内存不够用的时代，结果却发现，2.2的默认安装位置还是手机内存，只是装好以后可以用户可以去“应用程序管理”里，手动装安装的程序移动到SDCard，这不是坑爹嘛，像我这种手机装的软件有100多个的人，一个一个移动很是要老命。查了下发现，原来可以通过命令手动设置默认的安装路径。这对我们Android开发人员来说不是什么难事。其实普通用户也可以做到的。
首先去Android网站去下载android的SDK。网站是这里：http://developer.android.com/sdk/index.html。根据你的操作系统下载，Windows有两种格式。ZIP和EXE。随便下哪种都可以。下载完成后安装，ZIP格式的直接解压就可以，EXE的就根据提示一步一步点下去就好了【如果你这都不会，那后面的就别看了。。。】。但要记得你的安装路径，后面会用到。
再到你刚才安装的SDK的目录下，执行“SDK Manager.exe“，启动后会列出很长一个列表让你下载，其他的都别管，你只需要选择“Android SDK Platform-tools, revision  ×&#8221;就可以了。就像下图这样：

这个下载可能需要点时间，和你的网速有关【可能和RP也有点关系】。
下载完成后，把手机用USB线和电脑连起来。记得把手机的“USB调试”勾上。
然后点电脑的开始菜单，输入cmd，回车。
在跳出来的命令窗口输入命令转入刚才SDK的安装目录。比如我电脑的SDK在“D:\android-sdk-windows\platform-tools”这个位置。我就在命令窗口里选输入“D:”回车。然后输入“cd D:\android-sdk-windows\platform-tools”回车，就像下图：

然后接着输入“adb shell pm setInstallLocation 2”，回车。就完成了。
这行命令的作用就是改变Android手机的默认安装路径为2【2为SDCard】，如果先还原为默认的内存安装，只需要重新执行命令“adb shell pm setInstallLocation 0”，【0即为手机的内存】。这样以后你安装的所有软件就全面会安装到SDCard上，但有些软件只能安装在手机的内存中，这样就需要在安装完后到“应用程序管理”里，将软件移动到内存中即可。
相关文章2011年12月10日 -- 让Android自带的Gallery实现多点缩放，拖动和边界回弹效果，效果流畅2011年09月8日 -- 没装显卡驱动，开发cocos2d&#8212;x的问题2011年06月19日 -- Android面试题（一）2011年01月7日 -- 【火车票验证精灵】完成了2010年12月31日 -- &#8220;短信助手&#8221;正式开放下载]]></description>
			<content:encoded><![CDATA[<p>最近手机抽风，突然没信号或者信号很差，开始还以为是移动的问题，后来才知道自己错怪了10086。不得已只能刷机，把系统从2.1升到了2.2.1，原本以为升到了2.2就可以告别因装软件太多，内存不够用的时代，结果却发现，2.2的默认安装位置还是手机内存，只是装好以后可以用户可以去“应用程序管理”里，手动装安装的程序移动到SDCard，这不是坑爹嘛，像我这种手机装的软件有100多个的人，一个一个移动很是要老命。查了下发现，原来可以通过命令手动设置默认的安装路径。这对我们Android开发人员来说不是什么难事。其实普通用户也可以做到的。</p>
<p>首先去Android网站去下载android的SDK。网站是这里：<a title="http://developer.android.com/sdk/index.html" href="http://developer.android.com/sdk/index.html">http://developer.android.com/sdk/index.html</a>。根据你的操作系统下载，Windows有两种格式。ZIP和EXE。随便下哪种都可以。下载完成后安装，ZIP格式的直接解压就可以，EXE的就根据提示一步一步点下去就好了【如果你这都不会，那后面的就别看了。。。】。但要记得你的安装路径，后面会用到。<span id="more-648"></span></p>
<p>再到你刚才安装的SDK的目录下，执行“SDK Manager.exe“，启动后会列出很长一个列表让你下载，其他的都别管，你只需要选择“Android SDK Platform-tools, revision  ×&#8221;就可以了。就像下图这样：</p>
<p><a rel="lightbox" href="http://www.havenliu.com/wp-content/uploads/2011/08/Image.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 5px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image" src="http://www.havenliu.com/wp-content/uploads/2011/08/Image_thumb.jpg" border="0" alt="Image" width="564" height="429" /></a></p>
<p>这个下载可能需要点时间，和你的网速有关【可能和RP也有点关系】。</p>
<p>下载完成后，把手机用USB线和电脑连起来。记得把手机的“USB调试”勾上。</p>
<p>然后点电脑的开始菜单，输入cmd，回车。</p>
<p>在跳出来的命令窗口输入命令转入刚才SDK的安装目录。比如我电脑的SDK在“D:\android-sdk-windows\platform-tools”这个位置。我就在命令窗口里选输入“D:”回车。然后输入“cd D:\android-sdk-windows\platform-tools”回车，就像下图：</p>
<p><a rel="lightbox" href="http://www.havenliu.com/wp-content/uploads/2011/08/cmd-1.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 5px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="cmd-1" src="http://www.havenliu.com/wp-content/uploads/2011/08/cmd-1_thumb.png" border="0" alt="cmd-1" width="604" height="394" /></a></p>
<p>然后接着输入“adb shell pm setInstallLocation 2”，回车。就完成了。</p>
<p>这行命令的作用就是改变Android手机的默认安装路径为2【2为SDCard】，如果先还原为默认的内存安装，只需要重新执行命令“adb shell pm setInstallLocation 0”，【0即为手机的内存】。这样以后你安装的所有软件就全面会安装到SDCard上，但有些软件只能安装在手机的内存中，这样就需要在安装完后到“应用程序管理”里，将软件移动到内存中即可。</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2011年12月10日 -- <a href="http://www.havenliu.com/android/668.html" title="让Android自带的Gallery实现多点缩放，拖动和边界回弹效果，效果流畅">让Android自带的Gallery实现多点缩放，拖动和边界回弹效果，效果流畅</a></li><li>2011年09月8日 -- <a href="http://www.havenliu.com/android/652.html" title="没装显卡驱动，开发cocos2d&mdash;x的问题">没装显卡驱动，开发cocos2d&mdash;x的问题</a></li><li>2011年06月19日 -- <a href="http://www.havenliu.com/android/631.html" title="Android面试题（一）">Android面试题（一）</a></li><li>2011年01月7日 -- <a href="http://www.havenliu.com/android/598.html" title="【火车票验证精灵】完成了">【火车票验证精灵】完成了</a></li><li>2010年12月31日 -- <a href="http://www.havenliu.com/mylife/580.html" title="&#8220;短信助手&#8221;正式开放下载">&#8220;短信助手&#8221;正式开放下载</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.havenliu.com/android/648.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

