<?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>Mon, 14 May 2012 01:23:41 +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>【转】李承鹏：写在5.12的爱国帖</title>
		<link>http://www.havenliu.com/other/702.html</link>
		<comments>http://www.havenliu.com/other/702.html#comments</comments>
		<pubDate>Mon, 14 May 2012 01:23:16 +0000</pubDate>
		<dc:creator>Haven</dc:creator>
				<category><![CDATA[杂七杂八]]></category>

		<guid isPermaLink="false">http://www.havenliu.com/other/702.html</guid>
		<description><![CDATA[那年油菜花比往年晚开了整整一个月，人们并没有意识到什么。那时人们还相信专家，专家说花期推迟很正常，青蛙上街很正常。那天我正在书房赶一篇文章，地动时还以为家猫在脚下调皮。直到满书架的书往外飞，才明白是地震。   大楼摇晃、灯杆倾斜、天边发出异光，总之那个景象十分特殊，像末日降临。我拼命冲下楼，地面像煮沸了一样抖动，地面下像有无数双手在抓脚后跟，好容易跟一些邻居逃到小区外空地……慢慢地才知道都江堰死了很多人，北川已封路了，血浆都不够用了。那时我正处于一个爱国青年的尾声，纠结处热情最为猛烈，我认为报效国家的时候到了，要用我们的血肉筑起新的长城。我在头晚到处张罗捐款后，次日清晨与唐建光、郑褚进到北川。    可是，我在北川一中面临着人生很大的一个困扰。我无法解释为什么五层高的新楼倒塌后只有半个篮球场那么大，而几十年前修的旧楼竟没有倒塌。我也无法解释为什么楼房脆得像饼干一样且建渣里面没什么钢筋，连一楼的学生都没来得及逃脱。一个妇人一直在我身边走来走去，她已不太哭得出声，只指着那堆很渺小的建渣：看，那是我娃娃呀，手还在动，她还没死，但是我扯不出来她啊……那个情景令人崩溃，我看得见那个女娃娃碎花衣服的一角，还有其他孩子的衣角，他们中很多还在动，可按部队命令我们不能上前，因为过脆的废墟不能轻易站人，否则会引起二次崩塌。就这样眼看孩子们的身体还在动，与那些石头一起，慢慢变冷，而我们无能为力。    在此之前我还是个爱国青年，我相信生活的很多不幸是敌对势力造成的。我在球评里写“大刀向鬼子头上砍去”，这些总打败中国队的家伙是南京大屠杀的后裔。我骂过CNN长了口蹄疫，因为蒂弗莱说中国人几千年来都是暴民和垃圾。我也不反对抵制家乐福，觉得这一个侧面也可唤醒民主意识。我家离美领馆很近，99年美国导弹轰炸我驻南大使馆时，我也在美领馆外高举过抗议的拳头。同年前往美国采访时，我写过一句“像一枚导弹打进美国本土”，深觉这句子十分有力。    可站在北川学校废墟前，我很困惑。我还坚持过去一些爱国观点，但开始明白建渣里的钢筋并不是帝国主义悄悄抽走的，那些孩子也不是死于侵略者的魔爪，而死于自己人的脏手。我更困惑的是，为什么911死难者都有名字，而我们的孩子没有名字。我认为我们当然要用血肉筑起新的长城，可另一方面，长城也应该要保护我们的血肉。爱国主义应该是双向的，单向收费的不是爱国主义，是向君主效忠。    我从2008发生变化，如果晚年写自传，我会以2008为基点，在此之前我是一个混蛋。那段时间与其他一些志愿者天天在北川山里晃，救了一些老人和小孩，无意发现有一所希望小学远好无损甚至连玻璃窗都没怎么震碎，最后学生们在老师带领下翻过三座大山逃到山外。我问过校长和老师为什么出现这个奇迹，他们说得感谢那个监工。那个监工是捐款企业派来的，工程兵出身，修建过程中天天用小锤子敲水泥柱子听声音，他能从声音里听出有没有多掺沙子，圆石比例、水泥标号是否匹配，如果不合格就责令返工。老师告诉我，那些日子工地上除了施工声音就是这个监工跟人吵架的声音，除因质量问题吵，就因向当地政府追款吵。因为，企业捐助希望小学的款都要先交当地政府掌握，再由政府拨给具体施工单位……最后一架是关于操场的，终于成功追款修起了操场。大地震发生时，正是这个操场庇护了几百名孩子。    我问过这所希望小学是不是用了特殊标准才修得这么坚固。这个监工说：不，只是按国家普通建筑标准修建的。我又得知，这个监工监理了五所学校，在那场大地震中奇迹般地无一垮塌。他说：没什么奇迹，所谓奇迹，就是你修房子时，能在十年之前想到十年之后的事情。    可是他从来不能被主流媒体宣传，名字也一直不能公布，后又传出他所属的企业其实涉黑。前两年的一天晚上，他打来电话，说正在被精神病医生治疗着，老婆也离婚了，他现在想带着女儿逃出四川，问我能不能帮他远离这是非之地，在北方找一个工作……后来我们就断了联系。    我从2008年开始变化，一个人生平第一次看到无数的冤魂，肯定会变化。我持续四年的困惑：我们不仅不能公布那些死去孩子的名字，也不能公布救了很多孩子的监工的名字。今天是汶川大震四周年，这里正式公布他的名字：句艳东。    最近大家很爱谈爱国主义。在我看来，不要狭隘理解爱国主义就是敢于抵御外敌，爱国主义更是敢于抗争内贼，这如同你爱你们村，不仅表现在敢于同别村抢水源时打架，更表现平时勤恳耕种、爱护资源、不对本村妇女耍流氓……一方面欺负本村人民，一方面为了财主利益勇敢跟别村打架，这不叫爱国主义，这叫勇当家丁。所以我认为句艳东是十足的爱国者，他没去攻打钓鱼岛黄岩岛，可他救了很多孩子，他应当得到彰显，可弘扬名望的舞台被骗子占领着，我在灾区一月见闻，多少骗子假太阳光辉之名横行……我们深爱的国家正在逆淘汰、逆宣传、逆袭真相，如果一个国家的爱国主义宣传着一些骗子，这个爱国主义本身就是骗局。    5.13下午再次强烈余震，接命令必须外撤，走了几公里撤到山口时正碰到央视张泉灵在时空连线，无意中我一身雨水的形象被摄进镜头。刚到山下，一个素以厚道著称的央视记者打来电话：你丫真会出风头，没事儿你跑北川干嘛呀，抢我们台镜头。我说：日你妈。绝交至今。一月后回京碰一著名央视仁义大哥。聊起豆腐渣工程，我说：贪官该杀几个。仁义大哥深邃地看着我：不，中国的事情要慢慢来，否则又会乱，毕竟重建还要靠他们呀。又过三年，我不小心批评了倪萍“共和国脊梁”，该名仁义大哥电话里斥：你丫骂人倪大姐干什么呢，她可是好人哪。我在香港书展调侃于丹余秋雨伪善，仁义大哥再斥：想不到这几年你变成这种人，承鹏，咱不能只破坏不建设，不能见政府干的事都是错的。    我曾经如此欣赏仁义大哥，现在大家天各一方，形同陌路。他那些不知是矫造还是表演的关于公平正义的话在微博流传着，星光灿烂，粉丝推崇。以及类似仁义大哥这样的爱国者总说：不管国家有这样或那样的问题，可我们仍要爱这个国。我觉得这是个病句，我爱这个国，可我不能去爱制造豆腐渣工程的政府，更不能去爱给学校修豆腐渣给自己修豪华办公楼的政府官员。    我认为我仍是一个爱国者，可历经2008年的奥运、毒牛奶特别是汶川大地震，我对爱国主义重新定义。爱国主义肯定不是一边说是外人抢劫了我们，一边亲自掠夺国人财富的主义；不是一边说恶邻让我们石油紧缺，一边派出发改委只涨不降的主义；不是一边号召不要让强盗欺负我们的母亲，一边在大地震里让很多的母亲被欺侮的主义，她们看得见自己孩子的手还在动，却无能为力。那天我发了一条很爱国的微博：爱国主义就是，你并不拥有一寸私土，却宣称用生命保卫这片领土。这情形就像你并不在银行里拥有一分存款，却宣布誓死捍卫里面的金库……而且，此时你并不知道劫匪在哪里，银行保安是否把你当成劫匪。    这条微博伤害了很多爱国者的感情，纷纷斥责我为汉奸。我认为这又是个病句，在中国官不至厅局级，财产不过一个亿，每年不去开几个峰会哪好意思夸自己是汉奸。又说我是带路党，可是不拿几张绿卡儿女不开着法拉利在名校上学不在美国置几处房产哪有资格带路。还有说，母亲无论怎样打骂过我们，可毕竟是生我养我的亲妈啊。我就突然想起爱国者曲啸了——尼玛谁见过这么下毒手打骂自己孩子的亲妈？    [...]]]></description>
			<content:encoded><![CDATA[<p>那年油菜花比往年晚开了整整一个月，人们并没有意识到什么。那时人们还相信专家，专家说花期推迟很正常，青蛙上街很正常。那天我正在书房赶一篇文章，地动时还以为家猫在脚下调皮。直到满书架的书往外飞，才明白是地震。   <br />大楼摇晃、灯杆倾斜、天边发出异光，总之那个景象十分特殊，像末日降临。我拼命冲下楼，地面像煮沸了一样抖动，地面下像有无数双手在抓脚后跟，好容易跟一些邻居逃到小区外空地……慢慢地才知道都江堰死了很多人，北川已封路了，血浆都不够用了。那时我正处于一个爱国青年的尾声，纠结处热情最为猛烈，我认为报效国家的时候到了，要用我们的血肉筑起新的长城。我在头晚到处张罗捐款后，次日清晨与唐建光、郑褚进到北川。    <br />可是，我在北川一中面临着人生很大的一个困扰。我无法解释为什么五层高的新楼倒塌后只有半个篮球场那么大，而几十年前修的旧楼竟没有倒塌。我也无法解释为什么楼房脆得像饼干一样且建渣里面没什么钢筋，连一楼的学生都没来得及逃脱。一个妇人一直在我身边走来走去，她已不太哭得出声，只指着那堆很渺小的建渣：看，那是我娃娃呀，手还在动，她还没死，但是我扯不出来她啊……那个情景令人崩溃，我看得见那个女娃娃碎花衣服的一角，还有其他孩子的衣角，他们中很多还在动，可按部队命令我们不能上前，因为过脆的废墟不能轻易站人，否则会引起二次崩塌。就这样眼看孩子们的身体还在动，与那些石头一起，慢慢变冷，而我们无能为力。    <br />在此之前我还是个爱国青年，我相信生活的很多不幸是敌对势力造成的。我在球评里写“大刀向鬼子头上砍去”，这些总打败中国队的家伙是南京大屠杀的后裔。我骂过CNN长了口蹄疫，因为蒂弗莱说中国人几千年来都是暴民和垃圾。我也不反对抵制家乐福，觉得这一个侧面也可唤醒民主意识。我家离美领馆很近，99年美国导弹轰炸我驻南大使馆时，我也在美领馆外高举过抗议的拳头。同年前往美国采访时，我写过一句“像一枚导弹打进美国本土”，深觉这句子十分有力。    <br />可站在北川学校废墟前，我很困惑。我还坚持过去一些爱国观点，但开始明白建渣里的钢筋并不是帝国主义悄悄抽走的，那些孩子也不是死于侵略者的魔爪，而死于自己人的脏手。我更困惑的是，为什么911死难者都有名字，而我们的孩子没有名字。我认为我们当然要用血肉筑起新的长城，可另一方面，长城也应该要保护我们的血肉。爱国主义应该是双向的，单向收费的不是爱国主义，是向君主效忠。    <br />我从2008发生变化，如果晚年写自传，我会以2008为基点，在此之前我是一个混蛋。那段时间与其他一些志愿者天天在北川山里晃，救了一些老人和小孩，无意发现有一所希望小学远好无损甚至连玻璃窗都没怎么震碎，最后学生们在老师带领下翻过三座大山逃到山外。我问过校长和老师为什么出现这个奇迹，他们说得感谢那个监工。那个监工是捐款企业派来的，工程兵出身，修建过程中天天用小锤子敲水泥柱子听声音，他能从声音里听出有没有多掺沙子，圆石比例、水泥标号是否匹配，如果不合格就责令返工。老师告诉我，那些日子工地上除了施工声音就是这个监工跟人吵架的声音，除因质量问题吵，就因向当地政府追款吵。因为，企业捐助希望小学的款都要先交当地政府掌握，再由政府拨给具体施工单位……最后一架是关于操场的，终于成功追款修起了操场。大地震发生时，正是这个操场庇护了几百名孩子。    <br />我问过这所希望小学是不是用了特殊标准才修得这么坚固。这个监工说：不，只是按国家普通建筑标准修建的。我又得知，这个监工监理了五所学校，在那场大地震中奇迹般地无一垮塌。他说：没什么奇迹，所谓奇迹，就是你修房子时，能在十年之前想到十年之后的事情。    <br />可是他从来不能被主流媒体宣传，名字也一直不能公布，后又传出他所属的企业其实涉黑。前两年的一天晚上，他打来电话，说正在被精神病医生治疗着，老婆也离婚了，他现在想带着女儿逃出四川，问我能不能帮他远离这是非之地，在北方找一个工作……后来我们就断了联系。    <br />我从2008年开始变化，一个人生平第一次看到无数的冤魂，肯定会变化。我持续四年的困惑：我们不仅不能公布那些死去孩子的名字，也不能公布救了很多孩子的监工的名字。今天是汶川大震四周年，这里正式公布他的名字：句艳东。    <br />最近大家很爱谈爱国主义。在我看来，不要狭隘理解爱国主义就是敢于抵御外敌，爱国主义更是敢于抗争内贼，这如同你爱你们村，不仅表现在敢于同别村抢水源时打架，更表现平时勤恳耕种、爱护资源、不对本村妇女耍流氓……一方面欺负本村人民，一方面为了财主利益勇敢跟别村打架，这不叫爱国主义，这叫勇当家丁。所以我认为句艳东是十足的爱国者，他没去攻打钓鱼岛黄岩岛，可他救了很多孩子，他应当得到彰显，可弘扬名望的舞台被骗子占领着，我在灾区一月见闻，多少骗子假太阳光辉之名横行……我们深爱的国家正在逆淘汰、逆宣传、逆袭真相，如果一个国家的爱国主义宣传着一些骗子，这个爱国主义本身就是骗局。    <br />5.13下午再次强烈余震，接命令必须外撤，走了几公里撤到山口时正碰到央视张泉灵在时空连线，无意中我一身雨水的形象被摄进镜头。刚到山下，一个素以厚道著称的央视记者打来电话：你丫真会出风头，没事儿你跑北川干嘛呀，抢我们台镜头。我说：日你妈。绝交至今。一月后回京碰一著名央视仁义大哥。聊起豆腐渣工程，我说：贪官该杀几个。仁义大哥深邃地看着我：不，中国的事情要慢慢来，否则又会乱，毕竟重建还要靠他们呀。又过三年，我不小心批评了倪萍“共和国脊梁”，该名仁义大哥电话里斥：你丫骂人倪大姐干什么呢，她可是好人哪。我在香港书展调侃于丹余秋雨伪善，仁义大哥再斥：想不到这几年你变成这种人，承鹏，咱不能只破坏不建设，不能见政府干的事都是错的。    <br />我曾经如此欣赏仁义大哥，现在大家天各一方，形同陌路。他那些不知是矫造还是表演的关于公平正义的话在微博流传着，星光灿烂，粉丝推崇。以及类似仁义大哥这样的爱国者总说：不管国家有这样或那样的问题，可我们仍要爱这个国。我觉得这是个病句，我爱这个国，可我不能去爱制造豆腐渣工程的政府，更不能去爱给学校修豆腐渣给自己修豪华办公楼的政府官员。    <br />我认为我仍是一个爱国者，可历经2008年的奥运、毒牛奶特别是汶川大地震，我对爱国主义重新定义。爱国主义肯定不是一边说是外人抢劫了我们，一边亲自掠夺国人财富的主义；不是一边说恶邻让我们石油紧缺，一边派出发改委只涨不降的主义；不是一边号召不要让强盗欺负我们的母亲，一边在大地震里让很多的母亲被欺侮的主义，她们看得见自己孩子的手还在动，却无能为力。那天我发了一条很爱国的微博：爱国主义就是，你并不拥有一寸私土，却宣称用生命保卫这片领土。这情形就像你并不在银行里拥有一分存款，却宣布誓死捍卫里面的金库……而且，此时你并不知道劫匪在哪里，银行保安是否把你当成劫匪。    <br />这条微博伤害了很多爱国者的感情，纷纷斥责我为汉奸。我认为这又是个病句，在中国官不至厅局级，财产不过一个亿，每年不去开几个峰会哪好意思夸自己是汉奸。又说我是带路党，可是不拿几张绿卡儿女不开着法拉利在名校上学不在美国置几处房产哪有资格带路。还有说，母亲无论怎样打骂过我们，可毕竟是生我养我的亲妈啊。我就突然想起爱国者曲啸了——尼玛谁见过这么下毒手打骂自己孩子的亲妈？    <br />我其实相当地不反对打黄岩的，可反对只打黄岩不打黄贼。可爱国者逻辑是：打黄贼得给政府一些时间，打黄岩迫不及待。对此我只有一个解析：多少黄贼，假打黄岩之名逃于法网之外。就想起五四运动中的梅思平，假爱国之名火烧曹家，可日本人打来时第一批参加了汪伪政府。    <br />这样比爱国主义胸大肌其实很难证明真伪，说实话这三十年中国实力取得不小进步，至少近期不太可能有大批日本鬼子打进家门，所以那些组织义勇军半夜去炸碉堡的行为基本属于自我催眠的英雄幻想，不如让我们谈谈务实的爱国主义：爱国主义是给孩子修校舍时少一分回扣，多几根钢筋；爱国主义是少修点豪华办公楼，多建些实用农舍；爱国主义是少喝点爱心茅台，多吐槽些醒世真言；爱国主义是少宣传些虚假的英雄，多公布些逝去的名字；爱国主义是能让国民在这个国自由迁徙、念书，而不是平民子弟五证齐全才能就读京城；爱国主义爱的不是国家专政机器，而是去爱一种共同价值观……重要的不是拥护广袤的领土，更重要的是拥有生活的尊严。    <br />小小黄岩，以我军威武几排炮就打成粉齑，收回失地指日可待，以壮国威；重重汶川，多少魂灵在飞，不惩前毖后，君将空负民心。    <br />我是一个爱国者，所以，我在乎庞大的领土多一个小岛的名字，更在乎小小的纪念碑上回归数万亡灵的真实姓名——是为写在5.12的爱国帖。    <br />来源：李承鹏</p>
<h3  class="related_post_title">随机文章</h3><ul class="related_post"><li>2009年06月19日 -- <a href="http://www.havenliu.com/mylife/36.html" title="窗台的花枯了">窗台的花枯了</a></li><li>2009年08月3日 -- <a href="http://www.havenliu.com/other/179.html" title="Google收录速度加快了">Google收录速度加快了</a></li><li>2010年09月7日 -- <a href="http://www.havenliu.com/bike/495.html" title="青海湖骑行之三">青海湖骑行之三</a></li><li>2010年03月23日 -- <a href="http://www.havenliu.com/other/321.html" title="为Google送行">为Google送行</a></li><li>2010年06月30日 -- <a href="http://www.havenliu.com/goodarticle/462.html" title="【转】十年前你绝对没有看懂的《大话西游》，十年后你终于懂了……">【转】十年前你绝对没有看懂的《大话西游》，十年后你终于懂了……</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.havenliu.com/other/702.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>【转】三个故事伴你攻占钓鱼岛</title>
		<link>http://www.havenliu.com/other/701.html</link>
		<comments>http://www.havenliu.com/other/701.html#comments</comments>
		<pubDate>Thu, 26 Apr 2012 05:53:40 +0000</pubDate>
		<dc:creator>Haven</dc:creator>
				<category><![CDATA[杂七杂八]]></category>

		<guid isPermaLink="false">http://www.havenliu.com/other/701.html</guid>
		<description><![CDATA[三个故事伴你攻占钓鱼岛   文/余晓平    南海冲突日益尖锐，加上最近在石原慎太郎的煽动下，日本民间已经筹了不下二十笔款项用于购买钓鱼岛，领土争端摆到人们面前。我觉得收回钓鱼岛才是当务之急，很多人觉得管他日本人怎么折腾呢，我们攻上去把它占了就行。那么我要问，如果真的去打钓鱼岛你会上前线吗？先别急着回答，听听下面三个故事。    第一个故事的主人公是钓鱼岛上的日本钉子户。近日看到的新闻，足让我大吃一惊，这日本鬼子也太狡猾了吧，硬把自己的公民说成是那个岛的主人，这样那个岛就自然成了日本的领土，日本军人保护那个岛便成了天经地义的事情。    中国人一直声称钓鱼岛是中国的领土，光靠嘴说其实没用，如果画张地图就能决定国界，那把日本画成中国的一个省算了。当然有人拿出来我们祖先的一些证据来证明祖先曾经到过那个岛，其实这并不能说明那个岛现在就属于中国的领土。这个逻辑说不通，过两天小日本跑到东三省的什么地方挖出来个膏药旗，他就可以宣称东三省是日本领土了吗？说不过去吧。    不服气的话你翻翻关于国际相关的法则就知道了，现实控制，属地居民公投才是关键。日本人声称钓鱼岛属于某个日本公民，人家并不拿嘴说。而是从2002年开始，为了维护岛屿附近的治安，以及方便管理，每年向这位岛主支付相当于31万美元的租金，一直到现在让这小子得了三百多万美元。甚至石原慎太郎还特意表示政府需要出钱购买这个岛，那估计要上亿的美元。    不管你信不信，反正我不信，但糟糕的是日本人信了。其实国际上岛屿纠纷很多，像当年英国的马岛战争就挺热闹。夺岛要有个关键，那就是大家笃信这个岛就是自己的，舍得誓死捍卫才行。国际上对领土的公认，假如这个岛上没居民的话，没法公投怎么办呢？以实际控制为准则。    那么有聪明的中国人想出来一招，咱们也找个中国公民，把他当钓鱼岛的岛主，每年也发给他三十万美元，最后再花几个亿从这个人手里买下来，那么钓鱼岛不就名正言顺地成了中国的领土了吗？不管日本人信不信，糟糕的是大部分中国人都不会相信。    为什么没人相信呢？因为你整天看到身边的钉子户靠点着了自己来保卫自己的领土，本土上的钉子户还没人保护呢，谁还会去跑到钓鱼岛上去保护钉子户啊。那么日本大兵就特有动力，因为他们知道保护日本公民的利益就是保护自己的利益，有一天自己受到侵犯的时候，别人也会来舍命保卫自己。所以造成现在的状况就是日本人誓死保卫钓鱼岛，形成了国际上所谓现实控制的局面。    那么我们的大兵应该也会誓死保卫吧，只要是你能下命令。    下面我们来讲第二个故事：主人公叫杨帆，吉林某部队的一个班长。他的家在红升乡砺压村，去年他家的房子遭到强拆，家人和当地政府发生了严重矛盾，当他听说以后，伙同班里的三名战士，悄悄地把部队的枪偷出来，要跟着杨帆赶回家“报仇”。    这是中国军队里面极其恶劣的一个事件，一个军人的职责是保卫国家的财产，保卫国家的领土，但是谁来保护他们自己的家呢。那么一个百姓，也就是一个花钱供养部队的纳税人，你看到的是什么？你花钱给他们配的枪，他们忙不迭地先要保护自己。    那我问你，自己的家都给人拆了，谁来誓死保卫那么远的一个小岛，保卫了有啥用，跟你到底有什么关系？你说两百哩海洋权我们可以挖石油，那我小声问一句，油价能中国特色一下吗？现在军人在中国已经不像是军人了，自己保护自己的利益。我们且不说要求他们誓死保卫个什么小岛，你别在马路上横冲直撞行吗？就那么点小小的要求他们都做不到。    那么我们还有热血青年，不过我敢说，叫唤最凶的别说征兵打仗，你让他多出几块钱买颗子弹都玄。这些人只知道喊口号过瘾，要么就骂街过瘾，要么就意淫过瘾，正经的事根本就指望不上他们，这就是属于“要烧日货就烧别人家日货”的那种人，日本人来了第一个摇膏药旗的肯定也是他们。    [...]]]></description>
			<content:encoded><![CDATA[<p>三个故事伴你攻占钓鱼岛   <br />文/余晓平    <br />南海冲突日益尖锐，加上最近在石原慎太郎的煽动下，日本民间已经筹了不下二十笔款项用于购买钓鱼岛，领土争端摆到人们面前。我觉得收回钓鱼岛才是当务之急，很多人觉得管他日本人怎么折腾呢，我们攻上去把它占了就行。那么我要问，如果真的去打钓鱼岛你会上前线吗？先别急着回答，听听下面三个故事。    <br />第一个故事的主人公是钓鱼岛上的日本钉子户。近日看到的新闻，足让我大吃一惊，这日本鬼子也太狡猾了吧，硬把自己的公民说成是那个岛的主人，这样那个岛就自然成了日本的领土，日本军人保护那个岛便成了天经地义的事情。    <br />中国人一直声称钓鱼岛是中国的领土，光靠嘴说其实没用，如果画张地图就能决定国界，那把日本画成中国的一个省算了。当然有人拿出来我们祖先的一些证据来证明祖先曾经到过那个岛，其实这并不能说明那个岛现在就属于中国的领土。这个逻辑说不通，过两天小日本跑到东三省的什么地方挖出来个膏药旗，他就可以宣称东三省是日本领土了吗？说不过去吧。    <br />不服气的话你翻翻关于国际相关的法则就知道了，现实控制，属地居民公投才是关键。日本人声称钓鱼岛属于某个日本公民，人家并不拿嘴说。而是从2002年开始，为了维护岛屿附近的治安，以及方便管理，每年向这位岛主支付相当于31万美元的租金，一直到现在让这小子得了三百多万美元。甚至石原慎太郎还特意表示政府需要出钱购买这个岛，那估计要上亿的美元。    <br />不管你信不信，反正我不信，但糟糕的是日本人信了。其实国际上岛屿纠纷很多，像当年英国的马岛战争就挺热闹。夺岛要有个关键，那就是大家笃信这个岛就是自己的，舍得誓死捍卫才行。国际上对领土的公认，假如这个岛上没居民的话，没法公投怎么办呢？以实际控制为准则。    <br />那么有聪明的中国人想出来一招，咱们也找个中国公民，把他当钓鱼岛的岛主，每年也发给他三十万美元，最后再花几个亿从这个人手里买下来，那么钓鱼岛不就名正言顺地成了中国的领土了吗？不管日本人信不信，糟糕的是大部分中国人都不会相信。    <br />为什么没人相信呢？因为你整天看到身边的钉子户靠点着了自己来保卫自己的领土，本土上的钉子户还没人保护呢，谁还会去跑到钓鱼岛上去保护钉子户啊。那么日本大兵就特有动力，因为他们知道保护日本公民的利益就是保护自己的利益，有一天自己受到侵犯的时候，别人也会来舍命保卫自己。所以造成现在的状况就是日本人誓死保卫钓鱼岛，形成了国际上所谓现实控制的局面。    <br />那么我们的大兵应该也会誓死保卫吧，只要是你能下命令。    <br />下面我们来讲第二个故事：主人公叫杨帆，吉林某部队的一个班长。他的家在红升乡砺压村，去年他家的房子遭到强拆，家人和当地政府发生了严重矛盾，当他听说以后，伙同班里的三名战士，悄悄地把部队的枪偷出来，要跟着杨帆赶回家“报仇”。    <br />这是中国军队里面极其恶劣的一个事件，一个军人的职责是保卫国家的财产，保卫国家的领土，但是谁来保护他们自己的家呢。那么一个百姓，也就是一个花钱供养部队的纳税人，你看到的是什么？你花钱给他们配的枪，他们忙不迭地先要保护自己。    <br />那我问你，自己的家都给人拆了，谁来誓死保卫那么远的一个小岛，保卫了有啥用，跟你到底有什么关系？你说两百哩海洋权我们可以挖石油，那我小声问一句，油价能中国特色一下吗？现在军人在中国已经不像是军人了，自己保护自己的利益。我们且不说要求他们誓死保卫个什么小岛，你别在马路上横冲直撞行吗？就那么点小小的要求他们都做不到。    <br />那么我们还有热血青年，不过我敢说，叫唤最凶的别说征兵打仗，你让他多出几块钱买颗子弹都玄。这些人只知道喊口号过瘾，要么就骂街过瘾，要么就意淫过瘾，正经的事根本就指望不上他们，这就是属于“要烧日货就烧别人家日货”的那种人，日本人来了第一个摇膏药旗的肯定也是他们。    <br />最后我相信，在中国还是有那些真正的爱国勇士，他们会在中华民族最关键的时候挺身而出，不惜生命地为大众做出牺牲，这在我们国家的历史上不乏其人，到了今天，就在我们眼前或许就有。只是&#8230;&#8230;我要问一句，这样的人你曾经正眼看过他们吗？    <br />最后要讲的一位你肯定不知道，她叫许瑞琴，40岁，毕业于护理专业，非典时期，在人民医院担任临时工护士，成为了抗击非典一线的一员，也是在救治病人的过程中，感染了非典。经过注射激素治疗，虽然命是保下来了，但落得一身后遗症，如今穷困潦倒地熬日子。    <br />非典期间，真的可以说是国难当头，其危险的程度不亚于战争年代，因为如果疫情不能得到及时控制，我们都可能死于非命，非典过后，其实我们都属于劫后余生，显然那个时候看着一个个感染的人就这么很快地死去，让北京的人民笼罩在极度的恐惧当中。    <br />这个时候的医生和护士，绝对不亚于枪林弹雨当中的战士，但他们比战士更伟大，特别是那些普通医院的医生护士，因为他们平时没有开特权车横行霸道的机会，也没有军人的那种特殊待遇，用我们常说的话就是党和人民需要你的时候，需要你勇敢地往前冲。甚至肯定还有领导信誓旦旦地表示，党和人民是不会忘记你们的。    <br />但是刚刚过去十年，尽管是幸存下来了，但人基本上就是残废状态，前不久我在凤凰电视上看到这个人一瘸一拐的身影，想想当年她英勇地战斗在病房的第一线，就是属于堵枪眼的角色，可惜她很快就被人遗忘了，甚至后来人民医院由于她当时是临时工的身份而拒绝给她医药费。这十年里面她要自己去打官司争取医药费，无法正常参加工作，眼见人在衰老，往后的日子怎么熬下去。    <br />那么你设身处地想想这个人的心情，国难当头，你往前冲了，要么死，要么像她这样成了残废。后来的医院，一切像没发生一样，照样收红包，照样大把地从医药费里提成，替你垫背的人连日子都过不下去了都不去关心一下，这是什么世道啊？以后还有哪个倒霉蛋替你往前冲？我们可以为某个人去捐款资助，但是中国有千千万万这样的人，其余的人怎么办？    <br />这是活着的人，拖着残废一样的身体，肯定悔断肠子了，那些死了的冤魂呢？中国人总是让别人去牺牲，自己踩着别人的尸体往前走，以后谁给你垫背？我们就别扯什么祖国领土，民族利益，这个社会连个小老百姓都保护不好，连个冲锋陷阵的战士都没什么好待遇，那你这国家不就彻底完了。    <br />听完这三个故事，看看周围的一切，准备上前线吧。</p>
<h3  class="related_post_title">随机文章</h3><ul class="related_post"><li>2009年07月20日 -- <a href="http://www.havenliu.com/other/156.html" title="Picasa被和谐了">Picasa被和谐了</a></li><li>2010年05月27日 -- <a href="http://www.havenliu.com/web/446.html" title="Jquery html(val)使用注意">Jquery html(val)使用注意</a></li><li>2009年07月6日 -- <a href="http://www.havenliu.com/bike/115.html" title="2009年第96届环法自行车赛第二、三赛段视频">2009年第96届环法自行车赛第二、三赛段视频</a></li><li>2010年10月22日 -- <a href="http://www.havenliu.com/java/514.html" title="java生成复杂word文档的完美解决方案">java生成复杂word文档的完美解决方案</a></li><li>2011年08月21日 -- <a href="http://www.havenliu.com/android/648.html" title="设置Android系统程序的默认安装位置为SDCard">设置Android系统程序的默认安装位置为SDCard</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.havenliu.com/other/701.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>经典台词之【战争之王】</title>
		<link>http://www.havenliu.com/goodarticle/700.html</link>
		<comments>http://www.havenliu.com/goodarticle/700.html#comments</comments>
		<pubDate>Fri, 13 Apr 2012 01:06:20 +0000</pubDate>
		<dc:creator>Haven</dc:creator>
				<category><![CDATA[网络文摘]]></category>

		<guid isPermaLink="false">http://www.havenliu.com/goodarticle/700.html</guid>
		<description><![CDATA[战争之王 Lord of War (2005)     1.据统计，全世界有五千多万支私枪，平均每十二人就有一把，我们的问题是，怎样让剩下的十一人也拥有枪。     2.我把共产主义造的子弹卖给法西斯主义,我从来没卖给过本·拉登，不是因为道德问题，而是那是他的支票老是跳票。     3.当Yuri向非洲军阀推销大口径左轮枪时，军阀随手打死一个下属验枪，Yuri一把抓过枪：“你用过这把枪了！它变成二手货了，你必须买下它！”     4.每年死在抽烟上比死在武器上多得多,但是他们也不是照样卖,我卖的枪至少还带安全栓。     5.世界上最大的军火商是美国总统，他一天卖的比我一年卖的还多。     6.不卖军火打自己的国家就不能算国际军火商。     7.你要开个枪店？美国的枪店已经比麦当劳还多了。     8.世界上最大的军火出口国是美国、俄罗斯、英国、法国和中国……这五个国家也是联合国安理会常任理事国 。     9.核导弹都放在发射架里，你卖的ak47才是大规模杀伤性武器 。    [...]]]></description>
			<content:encoded><![CDATA[<p>战争之王 Lord of War (2005)    <br /> 1.据统计，全世界有五千多万支私枪，平均每十二人就有一把，我们的问题是，怎样让剩下的十一人也拥有枪。     <br />2.我把共产主义造的子弹卖给法西斯主义,我从来没卖给过本·拉登，不是因为道德问题，而是那是他的支票老是跳票。     <br />3.当Yuri向非洲军阀推销大口径左轮枪时，军阀随手打死一个下属验枪，Yuri一把抓过枪：“你用过这把枪了！它变成二手货了，你必须买下它！”     <br />4.每年死在抽烟上比死在武器上多得多,但是他们也不是照样卖,我卖的枪至少还带安全栓。     <br />5.世界上最大的军火商是美国总统，他一天卖的比我一年卖的还多。     <br />6.不卖军火打自己的国家就不能算国际军火商。     <br />7.你要开个枪店？美国的枪店已经比麦当劳还多了。     <br />8.世界上最大的军火出口国是美国、俄罗斯、英国、法国和中国……这五个国家也是联合国安理会常任理事国 。     <br />9.核导弹都放在发射架里，你卖的ak47才是大规模杀伤性武器 。     <br />10.往往最残忍的暴行都出自声称自己为自由战士的人们。     <br />11.在乌克兰买坦克时那个军官说“这玩意儿买六送一”     <br />12. “车上装的什么” “子弹” “干什么用” “个人用的” “10万发子弹个人用？” “我比较喜欢打枪” （这段话是用汉语说的……）     <br />13.第一次卖枪的感觉，很大程度上就像第一次做爱一样。你根本不知道自己在干嘛，虽然很刺激，但很快就结束了。     <br />14.先生…有没有兴趣看看S7地对空飞弹？中国制，过时的型号，用在现代军事战机上或许不行，不过打打商业客机还是挺不错的。$850而已，等于是白送给你了。     <br />15.你知道是谁会继承地球，军火商。因为其他人都在忙于相互残杀，生存的秘诀在于，永远不要加入战争。特别是你自己不要加入战争！     <br />16.用枪杆来换个go-vern-ment，比用选票更有效。     <br />17.自从冷战结束后，卡拉希尼可夫（AK47）成为了苏联主要的出口货物，接着是伏特加酒,鱼子酱和有自杀倾向的诗人。     <br />18.从14岁孩子的枪里射出的子弹和从40岁男人的枪里射出的子弹一样致命，也许更致命。     <br />19.我有个法国国旗。所以呢？横过来……就是荷兰。     <br />20.在全球艾滋病最流行的地方，4人中就有1人感染。安德烈和我开玩笑的方式，就是把两个漂亮的女人放到我床上，而且在方圆100英里内找不到避孕套。     <br />21.Yuri被国际刑警用枪指着头时，他看了一眼，惊喜的说：“新款MP5！你想要一个和它配套的消音器吗？”     <br />22.拿着镀金AK47的黑人总统儿子说：“请帮我弄只蓝博用的枪” Yuri问道：“第一集，第二集，还是第三集”（指电影《第一滴血》） “我只看过第一集” “嗯，M60，你要带穿甲弹的吗？”     <br />23.一个阿富汗武装分子在扫射，Yuri的弟弟怕被对方反击的流弹击中而缩着头，而Yuri看着AK47上飞出的一个个弹壳，耳里听到的却是收银机的“叮当”声。     <br />24.你可以和许多敌人战斗过后仍然存活下来，但是如果你和你自己战斗，你总是会输。     <br />25.我有种感觉，这大概不是列宁当年所倡导的财富重新分配，不过我可不是唯一提供给他们资本主义速成课程的人。     <br />26. 愤怒的士兵和满仓库的武器对于军火贩来说，真是美妙的组合。     <br />27.两个军火商之间开战是个麻烦事，因为双方都有用不完的弹药。     <br />28.人生的悲剧只有两种，一是得不到你想要的东西，二是得到了你想要的东西。 (One is not getting what you want,the other is getting it)     <br />29.根据我的经验，最成功的二人关系都是从撒谎和欺骗开始的，发展到最后也还是撒谎和欺骗，不如就这样开始吧。     <br />30.（乌克兰军火库里）有人会追查的，那时怎么办？我们把他也拉进来。     <br />31.我的一生都想远离暴力，但其实我更该接近它才对，这是人类的天性。最初人类遗骸的肋骨腔中，就有一个矛箭头。     <br />32.Yuri的将军叔叔让手下挡住国际刑警时命令道：“战斗到死，背后就是莫斯科！”     <br />33.“运伞到撒哈拉沙漠？” “我卖遮阳伞”     <br />34.新型乌兹自动手枪，体积虽小，但火力强大，这宝贝用的是九毫米凹头子弹，二十或二十五发可扩充弹夹，枪柄大小可调，消音器是标准装备，后坐力极低，减少四成，噪音减少六成，就算你现在朝我打完一整夹子弹，也不会吵醒隔壁的人。     <br />35.当美国撤离一个战区时，他们通常不把武器带走，因为运回去比买新的还贵。我们是按公斤卖的，虽然是二手货，但还是很好用。你需要多少公斤？五千公斤。     <br />36.卖枪就像卖吸尘器一样，打电话、谈价钱、处理定单。     <br />37.世界上共有三种军火交易方式，白色合法的，黑色非法的，还有我最中意的颜色——灰色。     <br />38.和西方45年来的敌对，造就了历史上最强大的武器，苏联有从地狱弄来的枪，堆的比山高，现在却没有敌人。     <br />39.我不是说做生意都很顺利，没有枪子儿跑的快，怎能叫军火贩子，有时军火还没运到，革命战争就已经爆发了。     <br />40.Yuri 对看管他的警官：“让我来告诉你将会发生什么，这样可以让你有所准备。很快，会有人来敲门，你会被叫到外面去。在过道里，会有一个官阶比你高的人站在那里。首先，他会祝贺你所做的一切，你使世界成为一个和平的地方，你会得到奖状或升职。然后他会告诉你，我需要被释放。你会反对，你也许会以辞职来要挟他，但是在最后，我会被释放。我被释放的原因，和你认为我会被判刑的原因是一样的。我和一些世界上称自己为领导人的人打交道，这些人当中的有一些人是你的敌人的敌人。世界上最大的军火交易商是你的老板，美国的总统，他一天卖的，比我一年卖的还多。有时，在枪支上找到他的指纹是一件很尴尬的事，有时，他需要像我这样的自由工作者，来支持那些他不可能支持的军队。所以,你称我为恶魔。但不幸的是，对你，我是一个必须要存在的恶魔。”</p>
<h3  class="related_post_title">随机文章</h3><ul class="related_post"><li>2009年07月5日 -- <a href="http://www.havenliu.com/bike/113.html" title="2009年第96届环法自行车赛第一赛段个人计时赛视频">2009年第96届环法自行车赛第一赛段个人计时赛视频</a></li><li>2010年09月15日 -- <a href="http://www.havenliu.com/mylife/506.html" title="分享一个可以防止QQ扫描硬盘的软件">分享一个可以防止QQ扫描硬盘的软件</a></li><li>2011年08月21日 -- <a href="http://www.havenliu.com/android/648.html" title="设置Android系统程序的默认安装位置为SDCard">设置Android系统程序的默认安装位置为SDCard</a></li><li>2009年08月20日 -- <a href="http://www.havenliu.com/other/201.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/goodarticle/700.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BBC最新报道：全球平均工资</title>
		<link>http://www.havenliu.com/other/699.html</link>
		<comments>http://www.havenliu.com/other/699.html#comments</comments>
		<pubDate>Sun, 01 Apr 2012 01:55:18 +0000</pubDate>
		<dc:creator>Haven</dc:creator>
				<category><![CDATA[杂七杂八]]></category>

		<guid isPermaLink="false">http://www.havenliu.com/other/699.html</guid>
		<description><![CDATA[BBC报道全球平均工资1,480美元，中国平均工资656美元。 又一次严重的拖了世界人民的后腿。。。。。。。。。。。
下面是详细图，会科学上网的童鞋可以自己到这里去看一下：    http://www.bbc.co.uk/news/magazine-17543356
友情提示：如果你从图的下面往上找，可能会更快一点找准自己的定位.
&#160;

随机文章2009年08月30日 -- 【骑单车看世界】骑行徽杭古道（一）2009年07月29日 -- Dom4j生成XML文件，并解决乱码问题2009年06月6日 -- 我喜欢的十个禅宗故事2009年07月20日 -- Picasa被和谐了2011年09月8日 -- 没装显卡驱动，开发cocos2d&#8212;x的问题]]></description>
			<content:encoded><![CDATA[<p>BBC报道全球平均工资1,480美元，中国平均工资656美元。 又一次严重的拖了世界人民的后腿。。。。。。。。。。。</p>
<p>下面是详细图，会科学上网的童鞋可以自己到这里去看一下：    <br /><a title="http://www.bbc.co.uk/news/magazine-17543356" href="http://www.bbc.co.uk/news/magazine-17543356">http://www.bbc.co.uk/news/magazine-17543356</a></p>
<p>友情提示：如果你从图的下面往上找，可能会更快一点找准自己的定位.</p>
<p>&#160;</p>
<p><a href="http://www.havenliu.com/wp-content/uploads/2012/04/cvzasdfa.jpg" rel="lightbox"><img style="background-image: none; border-right-width: 0px; margin: 0px 10px 5px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="cvzasdfa" border="0" alt="cvzasdfa" src="http://www.havenliu.com/wp-content/uploads/2012/04/cvzasdfa_thumb.jpg" width="656" height="679" /></a></p>
<h3  class="related_post_title">随机文章</h3><ul class="related_post"><li>2012年04月13日 -- <a href="http://www.havenliu.com/goodarticle/700.html" title="经典台词之【战争之王】">经典台词之【战争之王】</a></li><li>2010年08月26日 -- <a href="http://www.havenliu.com/goodarticle/481.html" title="爆笑三国之张飞流水账">爆笑三国之张飞流水账</a></li><li>2009年07月9日 -- <a href="http://www.havenliu.com/bike/139.html" title=" 2009年第96届环法自行车赛第六站视频"> 2009年第96届环法自行车赛第六站视频</a></li><li>2009年08月3日 -- <a href="http://www.havenliu.com/mylife/176.html" title="如何知道你的身體正常了-来自传统中医">如何知道你的身體正常了-来自传统中医</a></li><li>2010年12月22日 -- <a href="http://www.havenliu.com/goodarticle/569.html" title="一个关于楼市的冷笑话">一个关于楼市的冷笑话</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.havenliu.com/other/699.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android在自定义View（SurfaceView）中实现进度条Progress</title>
		<link>http://www.havenliu.com/java/689.html</link>
		<comments>http://www.havenliu.com/java/689.html#comments</comments>
		<pubDate>Tue, 13 Mar 2012 06:23:23 +0000</pubDate>
		<dc:creator>Haven</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[SurfaceView]]></category>
		<category><![CDATA[自定义]]></category>

		<guid isPermaLink="false">http://www.havenliu.com/?p=689</guid>
		<description><![CDATA[Android本身带有Progress控件。可以在布局中灵活使用，但如果是在自定义的View或者SurfaceView中使用，就需要自己实现，其实不难，只要熟悉了android的PorterDuff，就能利用PorterDuff的遮罩效果方便的实现进度条。
PorterDuff.Mode的灵活使用可以实现很多强大的功能，比如以前比较流行的美女擦玻璃，在屏幕上用手指绘图或橡皮檫等功能。
下面是源码，老规矩，完整源码中文章末尾下载。
先上一张效果图：


Main.java,这是个Activity，地球人都看的懂

?Download Main.java1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.havenliu.progressdemo;
&#160;
import android.app.Activity;
import android.os.Bundle;
import android.view.Display;
import android.view.Window;
import android.view.WindowManager;
/**
 *
 * http://www.havenliu.com/other/689.html
 * @author HavenLiu 
 *
 */
public class Main extends Activity &#123;
	public static int screen_width;// 屏幕的宽度
	public static int screen_height;// 屏幕的高度
	//图片资源根据游戏屏幕的缩放比例
	public static float zoomRate;
	public static boolean isRun;
&#160;
	@Override
	public void onCreate&#40;Bundle savedInstanceState&#41; &#123;
		super.onCreate&#40;savedInstanceState&#41;;
		// 全屏显示窗口
		requestWindowFeature&#40;Window.FEATURE_NO_TITLE&#41;;
		getWindow&#40;&#41;.setFlags&#40;WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN&#41;;
		getWindow&#40;&#41;.setFlags&#40;WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS&#41;;
		isRun = true;
&#160;
		Display display = getWindowManager&#40;&#41;.getDefaultDisplay&#40;&#41;;
&#160;
		screen_width = display.getWidth&#40;&#41;;
		screen_height = display.getHeight&#40;&#41;;
		zoomRate = getZoomRate&#40;&#41;;
		setContentView&#40;new MyView&#40;this&#41;&#41;;
	&#125;
&#160;
	/**
	 [...]]]></description>
			<content:encoded><![CDATA[<p>Android本身带有Progress控件。可以在布局中灵活使用，但如果是在自定义的View或者SurfaceView中使用，就需要自己实现，其实不难，只要熟悉了android的PorterDuff，就能利用PorterDuff的遮罩效果方便的实现进度条。</p>
<p>PorterDuff.Mode的灵活使用可以实现很多强大的功能，比如以前比较流行的美女擦玻璃，在屏幕上用手指绘图或橡皮檫等功能。</p>
<p>下面是源码，老规矩，完整源码中文章末尾下载。</p>
<p>先上一张效果图：<br />
<img src="http://www.havenliu.com/wp-content/uploads/2012/03/201203131416.png" alt="Progress效果" title="Progress效果" width="224" height="442" class="alignnone size-full wp-image-691" /><br />
<span id="more-689"></span><br />
Main.java,这是个Activity，地球人都看的懂</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="left2">Download <a href="http://www.havenliu.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=689&amp;download=Main.java">Main.java</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6893"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
</pre></td><td class="code" id="p689code3"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.havenliu.progressdemo</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.app.Activity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os.Bundle</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.Display</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.Window</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.WindowManager</span><span style="color: #339933;">;</span>
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 *
 * http://www.havenliu.com/other/689.html
 * @author HavenLiu 
 *
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">int</span> screen_width<span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// 屏幕的宽度</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">int</span> screen_height<span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// 屏幕的高度</span>
	<span style="color: #666666; font-style: italic;">//图片资源根据游戏屏幕的缩放比例</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">float</span> zoomRate<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">boolean</span> isRun<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> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<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;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// 全屏显示窗口</span>
		requestWindowFeature<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Awindow+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Window</span></a>.<span style="color: #006633;">FEATURE_NO_TITLE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		getWindow<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setFlags</span><span style="color: #009900;">&#40;</span>WindowManager.<span style="color: #006633;">LayoutParams</span>.<span style="color: #006633;">FLAG_FULLSCREEN</span>, WindowManager.<span style="color: #006633;">LayoutParams</span>.<span style="color: #006633;">FLAG_FULLSCREEN</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		getWindow<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setFlags</span><span style="color: #009900;">&#40;</span>WindowManager.<span style="color: #006633;">LayoutParams</span>.<span style="color: #006633;">FLAG_LAYOUT_NO_LIMITS</span>, WindowManager.<span style="color: #006633;">LayoutParams</span>.<span style="color: #006633;">FLAG_LAYOUT_NO_LIMITS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isRun <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
		Display display <span style="color: #339933;">=</span> getWindowManager<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getDefaultDisplay</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		screen_width <span style="color: #339933;">=</span> display.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		screen_height <span style="color: #339933;">=</span> display.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		zoomRate <span style="color: #339933;">=</span> getZoomRate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		setContentView<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> MyView<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</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: #008000; font-style: italic; font-weight: bold;">/**
	 * 计算图片的缩放比例，这要是为了让图片能自适应屏幕大小
	 * 
	 * @return
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">float</span> getZoomRate<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> rate <span style="color: #339933;">=</span> 1f<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">float</span> rate_width <span style="color: #339933;">=</span> screen_width <span style="color: #339933;">/</span> 44f<span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// 图片资源的宽度为44px</span>
		<span style="color: #000066; font-weight: bold;">float</span> rate_height <span style="color: #339933;">=</span> screen_height <span style="color: #339933;">/</span> 547f<span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// 图片资源的高度为547px</span>
		rate <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>rate_width, rate_height<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> rate<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> onDestroy<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;">super</span>.<span style="color: #006633;">onDestroy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isRun <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>MyView.java:是一个自定义View，为了简单，这没有使用SurfaceView，其实是一样的。里面实现了对分辨率的自适应，可以在不同分辨率下保证progress的精准。</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="left2">Download <a href="http://www.havenliu.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=689&amp;download=MyView.java">MyView.java</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6894"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
</pre></td><td class="code" id="p689code4"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.havenliu.progressdemo</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.BitmapFactory</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.graphics.Canvas</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.Paint</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.graphics.PorterDuff.Mode</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.graphics.PorterDuffXfermode</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>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * 自定义View，也可以用SurfaceView代替
 * http://www.havenliu.com/other/689.html
 * @author HavenLiu 
 *
 *
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyView <span style="color: #000000; font-weight: bold;">extends</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> <span style="color: #000000; font-weight: bold;">implements</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;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// 游戏总时间，单位：秒</span>
	<span style="color: #000000; font-weight: bold;">public</span> <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;">int</span> TOTALTIME <span style="color: #339933;">=</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// 刷新频率：毫秒</span>
	<span style="color: #000000; font-weight: bold;">public</span> <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;">int</span> REFRESH <span style="color: #339933;">=</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> Bitmap img_progress<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> Bitmap img_progress_bg<span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// 屏幕每次刷新，progressBar应减去的长度</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">float</span> step<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Apaint+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Paint</span></a> paint<span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// progressBar的中长度</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">float</span> progress<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> MyView<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>
		paint <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Apaint+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Paint</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		paint.<span style="color: #006633;">setDither</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		initBitmap<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		initProgress<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Athread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Thread</span></a><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">start</span><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> initBitmap<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		Bitmap bitmap <span style="color: #339933;">=</span> BitmapFactory.<span style="color: #006633;">decodeResource</span><span style="color: #009900;">&#40;</span>getResources<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, R.<span style="color: #006633;">drawable</span>.<span style="color: #006633;">timebar</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		Matrix matrix <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>
		matrix.<span style="color: #006633;">postScale</span><span style="color: #009900;">&#40;</span>Main.<span style="color: #006633;">zoomRate</span>, Main.<span style="color: #006633;">zoomRate</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		img_progress <span style="color: #339933;">=</span> Bitmap.<span style="color: #006633;">createBitmap</span><span style="color: #009900;">&#40;</span>bitmap, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, bitmap.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, bitmap.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, matrix, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		Bitmap bitmap_bg <span style="color: #339933;">=</span> BitmapFactory.<span style="color: #006633;">decodeResource</span><span style="color: #009900;">&#40;</span>getResources<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, R.<span style="color: #006633;">drawable</span>.<span style="color: #006633;">timebar_bg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		img_progress_bg <span style="color: #339933;">=</span> Bitmap.<span style="color: #006633;">createBitmap</span><span style="color: #009900;">&#40;</span>bitmap_bg, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, bitmap_bg.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, bitmap_bg.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, matrix, <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: #008000; font-style: italic; font-weight: bold;">/**
	 * 初始化progressBar相关参数
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> initProgress<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;">int</span> _totalTime <span style="color: #339933;">=</span> TOTALTIME <span style="color: #339933;">*</span> <span style="color: #cc66cc;">1000</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> refreshTimes <span style="color: #339933;">=</span> _totalTime <span style="color: #339933;">/</span> REFRESH<span style="color: #339933;">;</span>
		progress <span style="color: #339933;">=</span> 547.0f <span style="color: #339933;">*</span> Main.<span style="color: #006633;">zoomRate</span><span style="color: #339933;">;</span>
		step <span style="color: #339933;">=</span> progress <span style="color: #339933;">/</span> refreshTimes<span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// 547为滚动条的高度</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> onDraw<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acanvas+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Canvas</span></a> canvas<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;">onDraw</span><span style="color: #009900;">&#40;</span>canvas<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		canvas.<span style="color: #006633;">drawARGB</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span>, <span style="color: #cc66cc;">157</span>, <span style="color: #cc66cc;">157</span>, <span style="color: #cc66cc;">157</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// 居中</span>
		canvas.<span style="color: #006633;">drawBitmap</span><span style="color: #009900;">&#40;</span>img_progress, Main.<span style="color: #006633;">screen_width</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">-</span> img_progress.<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: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// 背景条：蓝色</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">int</span> rc <span style="color: #339933;">=</span> canvas.<span style="color: #006633;">saveLayer</span><span style="color: #009900;">&#40;</span>Main.<span style="color: #006633;">screen_width</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">-</span> img_progress.<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: #cc66cc;">2</span>, img_progress.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> progress, Main.<span style="color: #006633;">screen_width</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">+</span> img_progress.<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: #cc66cc;">2</span>,
				img_progress.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000066; font-weight: bold;">null</span>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acanvas+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Canvas</span></a>.<span style="color: #006633;">ALL_SAVE_FLAG</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		paint.<span style="color: #006633;">setFilterBitmap</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		canvas.<span style="color: #006633;">drawRect</span><span style="color: #009900;">&#40;</span>Main.<span style="color: #006633;">screen_width</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">-</span> img_progress.<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: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, Main.<span style="color: #006633;">screen_width</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">+</span> img_progress.<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: #cc66cc;">2</span>, img_progress.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, paint<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//Xfermode的类型很重要，不同的Mode有不同的效果。具体可以参考后面的图片</span>
		paint.<span style="color: #006633;">setXfermode</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> PorterDuffXfermode<span style="color: #009900;">&#40;</span>Mode.<span style="color: #006633;">SRC_IN</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		canvas.<span style="color: #006633;">drawBitmap</span><span style="color: #009900;">&#40;</span>img_progress_bg, Main.<span style="color: #006633;">screen_width</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">-</span> img_progress.<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: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, paint<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		paint.<span style="color: #006633;">setXfermode</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		canvas.<span style="color: #006633;">restoreToCount</span><span style="color: #009900;">&#40;</span>rc<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;">void</span> run<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;">while</span> <span style="color: #009900;">&#40;</span>Main.<span style="color: #006633;">isRun</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			postInvalidate<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>progress <span style="color: #339933;">&lt;=</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;">// Game Over.....</span>
				<span style="color: #666666; font-style: italic;">// do something......</span>
<span style="color: #666666; font-style: italic;">//				Log.i(&quot;&quot;, &quot;Game over.........you lost!&quot;);</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				progress <span style="color: #339933;">-=</span> step<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
				<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Athread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Thread</span></a>.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span>REFRESH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainterruptedexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">InterruptedException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				e.<span style="color: #006633;">printStackTrace</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: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>PorterDuff.Mode的各种效果：<br />
<img src="http://www.havenliu.com/wp-content/uploads/2012/03/20110606010.png" alt="PorterDuff.Mode效果" title="PorterDuff.Mode效果" width="328" height="490" class="alignnone size-full wp-image-692" /></p>
<p>完整源码：<a href="http://www.havenliu.com/download/undelete/ProgressDemo.zip">点击下载</a></p>
<p>天下网络一大抄，如果你转载，请务必注明<a href="http://www.havenliu.com/other/689.html">出处</a>：http://www.havenliu.com/other/689.html，谢谢！</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年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/java/689.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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用户资料，泄漏信息：真实姓名、电子邮件、家庭住址、，电话
随机文章2010年09月7日 -- 青海湖骑行之三2010年04月8日 -- 转摘一篇关于目前房价的文章2011年02月17日 -- 【网摘】6岁女童每天捉虫捡米粒养鸡以攒钱交学费2010年05月19日 -- 【好文推荐】从十万到八千里2009年07月5日 -- 2009年第96届环法自行车赛第一赛段个人计时赛视频]]></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>2009年06月30日 -- <a href="http://www.havenliu.com/goodarticle/61.html" title="惠普前总裁孙振耀指点职业规划（一）">惠普前总裁孙振耀指点职业规划（一）</a></li><li>2011年01月15日 -- <a href="http://www.havenliu.com/goodarticle/603.html" title="经典语录:一个人的命运决定于晚上8点到10点之间">经典语录:一个人的命运决定于晚上8点到10点之间</a></li><li>2009年07月23日 -- <a href="http://www.havenliu.com/bike/159.html" title="2009年第96届环法自行车赛第十五、十六、十七，十八站视频">2009年第96届环法自行车赛第十五、十六、十七，十八站视频</a></li><li>2010年10月26日 -- <a href="http://www.havenliu.com/other/523.html" title=" 烟花易冷"> 烟花易冷</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/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一社会的蛀虫！【更新一下：今天乘一时之快，写了前面这几句话，晚上回来觉得有点不妥。在事情还没弄清楚之前，或许我不该这样怪罪金山，毕竟现在说的数据是金山员工泄漏的也是从网上看来的，并没有官方的说法，所有下是把前面的话划下线吧。。。。最近火气比较大，容易走火！】
这种事情要是发生在国外不知道会怎样！
随机文章2010年12月27日 -- 惭愧的一件事情2009年06月16日 -- 回家归来2009年12月27日 -- 伊朗起义了(重新更新了大量图片)2012年04月26日 -- 【转】三个故事伴你攻占钓鱼岛2009年08月8日 -- Javascript 操作select控件大全（新增、修改、删除、选中、清空、判断存在等）]]></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>2010年05月6日 -- <a href="http://www.havenliu.com/mylife/409.html" title="西塘游记">西塘游记</a></li><li>2011年04月26日 -- <a href="http://www.havenliu.com/mylife/627.html" title="此文无标题">此文无标题</a></li><li>2011年02月22日 -- <a href="http://www.havenliu.com/goodarticle/616.html" title="江城子">江城子</a></li><li>2009年07月14日 -- <a href="http://www.havenliu.com/bike/145.html" title="2009年第96届环法自行车赛第九、十站视频">2009年第96届环法自行车赛第九、十站视频</a></li><li>2009年08月8日 -- <a href="http://www.havenliu.com/web/181.html" title="Javascript 操作select控件大全（新增、修改、删除、选中、清空、判断存在等）">Javascript 操作select控件大全（新增、修改、删除、选中、清空、判断存在等）</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年06月30日 -- 【转】十年前你绝对没有看懂的《大话西游》，十年后你终于懂了……2010年02月24日 -- 朋友的事2012年04月1日 -- BBC最新报道：全球平均工资2011年12月9日 -- 发现个不错的网盘：酷盘2011年12月29日 -- 密码泄漏不完全总结]]></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>2010年06月30日 -- <a href="http://www.havenliu.com/goodarticle/462.html" title="【转】十年前你绝对没有看懂的《大话西游》，十年后你终于懂了……">【转】十年前你绝对没有看懂的《大话西游》，十年后你终于懂了……</a></li><li>2011年01月15日 -- <a href="http://www.havenliu.com/goodarticle/603.html" title="经典语录:一个人的命运决定于晚上8点到10点之间">经典语录:一个人的命运决定于晚上8点到10点之间</a></li><li>2009年09月20日 -- <a href="http://www.havenliu.com/web/238.html" title="JQuery基础入门-输入验证">JQuery基础入门-输入验证</a></li><li>2009年12月27日 -- <a href="http://www.havenliu.com/goodarticle/292.html" title="伊朗起义了(重新更新了大量图片)">伊朗起义了(重新更新了大量图片)</a></li><li>2009年08月3日 -- <a href="http://www.havenliu.com/mylife/176.html" title="如何知道你的身體正常了-来自传统中医">如何知道你的身體正常了-来自传统中医</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('p668code7'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6687"><td class="code" id="p668code7"><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('p668code8'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6688"><td class="code" id="p668code8"><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>2012年03月13日 -- <a href="http://www.havenliu.com/java/689.html" title="Android在自定义View（SurfaceView）中实现进度条Progress">Android在自定义View（SurfaceView）中实现进度条Progress</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年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/668.html/feed</wfw:commentRss>
		<slash:comments>73</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，一边就自动同步了。相当方便，唯一不足的是没有回退功能。但这样已经很不错了。
呃。。。搞的我像个枪手一样的。向毛主席保证我绝对不是枪手，也不是啥五毛党。要注册的狂击这里吧。
随机文章2009年06月18日 -- 夜骑2010年09月7日 -- 青海湖骑行之三2009年07月2日 -- 网络上收集的搞笑签名2009年06月16日 -- 回家归来2011年04月26日 -- 此文无标题]]></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>2011年07月17日 -- <a href="http://www.havenliu.com/mylife/641.html" title="杂。。。。">杂。。。。</a></li><li>2011年11月4日 -- <a href="http://www.havenliu.com/mylife/664.html" title="感冒了">感冒了</a></li><li>2010年09月23日 -- <a href="http://www.havenliu.com/mylife/508.html" title="换了个手机">换了个手机</a></li><li>2010年06月30日 -- <a href="http://www.havenliu.com/goodarticle/462.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/666.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

