android模拟翻书效果

android模拟翻书效果

ID:14734150

大小:174.00 KB

页数:8页

时间:2018-07-30

android模拟翻书效果_第1页
android模拟翻书效果_第2页
android模拟翻书效果_第3页
android模拟翻书效果_第4页
android模拟翻书效果_第5页
资源描述:

《android模拟翻书效果》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、第一页和第二页中间,能看到第一页的后半部分和第二页的前半部分,中间是黑色的分割线。         第1页,上面显示的数字是1。        第2页,上面显示的数字是2. 接下来贴上主要代码。首先是这个FlatWorkSpace,沿用网上一帖子的取名,主要是因为Launcher里面叫WorkSpace.这个是一个ViewGroup,在创建的时候添加了三个ImageView。然后构造方法的重写就不用说了。主要要重写的方法有dispatchDraw,onMeasure,onLayout,computeScroll,onTouchE

2、vent,他们的作用从源代码中可以看出来。packagecom.hhg.test.testscroll;importcom.hhg.test.testscroll.R;importandroid.content.Context;importandroid.graphics.Canvas;importandroid.util.AttributeSet;importandroid.view.MotionEvent;importandroid.view.View;importandroid.view.ViewGroup;importa

3、ndroid.widget.ImageView;importandroid.widget.Scroller;publicclassFlatWorkSpaceextendsViewGroup{   privatefloatmTouchX;   privatefloatmLastMotionX;   privateintmActivePointerId=-1;   privateScrollermScroller;   publicFlatWorkSpace(Contextcontext,AttributeSetattrs,intd

4、efStyle){       super(context,attrs,defStyle);   }   publicFlatWorkSpace(Contextcontext,AttributeSetattrs){       this(context,attrs,0);   }   publicvoidinitScreen(){       Contextcontext=getContext();       mScroller=newScroller(context);       for(inti=0;i<3;i++){ 

5、          this.addView(newImageView(this.getContext()),i);       }       ((ImageView)this.getChildAt(0)).setImageResource(R.drawable.view_1);       ((ImageView)this.getChildAt(1)).setImageResource(R.drawable.view_2);       ((ImageView)this.getChildAt(2)).setImageReso

6、urce(R.drawable.view_3);   }   @Override   protectedvoiddispatchDraw(Canvascanvas){       finallongdrawingTime=getDrawingTime();       finalintcount=getChildCount();       for(inti=0;i

7、Override   protectedvoidonMeasure(intwidthMeasureSpec,intheightMeasureSpec){       super.onMeasure(widthMeasureSpec,heightMeasureSpec);       finalintwidthMode=MeasureSpec.getMode(widthMeasureSpec);       if(widthMode!=MeasureSpec.EXACTLY){           thrownewIllegalS

8、tateException("WorkspacecanonlybeusedinEXACTLYmode.");       }       finalintheightMode=MeasureSpec.getMode(heightMeasureSpec);    

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。