ipad中的iBook的翻页效果是如何实现的,用android能不能实现类似的翻书效果或是动画呢?

解决方案 »

  1.   

    把M3老版本SDK里的PageTunner这个widget的class文件反编译就ok了  你自己在写一个就好
    这个原来有的 因为不够泛所以就被android移除了
      

  2.   

    2D可以考虑通过贴图+Mesh的方式来实现。3D的话,需要将整个ap的界面都用opengl来实现,不过效果比2D的好很多。
      

  3.   

      现在的android版本是否支持3D效果, 这个不太好说, 我觉得还没出这个吧, 要是想做翻页的效果, 觉得只能自己去写算法, 主要的是布局中, 控件矩阵的转换, 这个需要自己琢磨下, 不过, 倒是觉得可以实现。 但是效率如何, 我不敢肯定。
      

  4.   


    能说一下用2D的具体思路吗?thks
      

  5.   

    android中日历是可以翻页,向上翻页就是上一个月,向下翻页就是下一个月。
    效果就是模拟日常中使用的日历的翻页方式,有个动画效果。
      

  6.   

    http://android.toolib.com/sdk/older_releases.html
    这里可以下archive 官方的那个应该也可以的 好象有问题
    我帮你弄了 你看看把。。 差什么在说第一部分package android.widget;import android.R.styleable;
    import android.content.Context;
    import android.content.Resources.StyledAttributes;
    import android.graphics.Canvas;
    import android.graphics.Canvas.ClipMode;
    import android.graphics.Path;
    import android.graphics.PointF;
    import android.graphics.Rect;
    import android.graphics.drawable.Drawable;
    import android.os.Handler;
    import android.os.Message;
    import android.os.SystemClock;
    import android.util.AttributeSet;
    import android.view.View;
    import java.util.Map;public class PageTurner extends RelativeLayout
    {
      private static final int CORNER_RIGHT_MASK = 1;
      private static final int CORNER_TOP_MASK = 2;
      public static final int CORNER_BOTTOM_LEFT = 0;
      public static final int CORNER_BOTTOM_RIGHT = 1;
      public static final int CORNER_TOP_LEFT = 2;
      public static final int CORNER_TOP_RIGHT = 3;
      private static final int INVALIDATE = 1;
      private static final int INITIAL_TIME_DELAY = 100;
      private static final int TIME_DELAY = 10;
      private static final int TIME_STEPS = 30;
      private boolean mPageTurning;
      private boolean mStepping;
      private long mNextTime;
      private int mTimeStep;
      private int mDrawnTimeStep;
      private int mCorner;
      private Drawable mBackPage;
      private Drawable mPageBackground;
      private Path mForegroundPath;
      private Path mBackPagePath;
      private Path mBackgroundPath;
      private float mRotation;
      private Rect mChildRect = new Rect();
      private int mOuterOffsetX;
      private int mOuterOffsetY;
      private float mPivotX;
      private int mPageId;
      private Page mPage;
      private PointF mPageTurnCorner = new PointF();
      private PointF mOppositeCorner = new PointF();
      private PointF mPageDim = new PointF();  private final Handler mHandler = new Handler() {
        public void handleMessage(Message msg) {
          if (msg.what != 1) {
            return;
          }
          PageTurner.this.invalidate();
          if (PageTurner.this.mStepping) {
            return;
          }
          msg = obtainMessage(1);
          long current = SystemClock.uptimeMillis();
          if (PageTurner.this.mNextTime < current) {
            PageTurner.access$102(PageTurner.this, current + 10L);
          }
          sendMessageAtTime(msg, PageTurner.this.mNextTime);
          PageTurner.access$114(PageTurner.this, 10L);
        }
      };  public PageTurner(Context context)
      {
        super(context);
      }  public PageTurner(Context context, AttributeSet attrs, Map inflateParams) {
        super(context, attrs, inflateParams);
        Resources.StyledAttributes a = context.obtainStyledAttributes(attrs, R.styleable.PageTurner);    this.mBackPage = a.getDrawable(1);
        this.mPageBackground = a.getDrawable(0);    this.mPageId = a.getResourceID(3, -1);    this.mCorner = a.getInt(2, 0);
      }  protected void onFinishInflate()
      {
        super.onFinishInflate();
        if (this.mPageId != -1) {
          this.mPage = ((Page)findViewById(this.mPageId));
          if (this.mPage != null)
            this.mPage.setPageTurner(this);
        }
      }  public void setPageId(int pageId)
      {
        this.mPageId = pageId;
        this.mPage = ((Page)findViewById(this.mPageId));
        if (this.mPage != null)
          this.mPage.setPageTurner(this);
      }  public int getPageId()
      {
        return this.mPageId;
      }  public void setPage(Page page)
      {
        this.mPage = page;
      }  public Page getPage()
      {
        return this.mPage;
      }  public void setCorner(int corner)
      {
        this.mCorner = corner;
      }  public int getCorner()
      {
        return this.mCorner;
      }  protected void dispatchDraw(Canvas canvas)
      {
        if ((this.mPageTurning) && (this.mPage != null) && (computePageTurn()))
        {
          this.mPage.setClipPath(this.mForegroundPath);
        }    super.dispatchDraw(canvas);    if (this.mPageTurning) {
          drawBackground(canvas);
          drawBackPage(canvas);      if (!updateTimeStep())
          {
            this.mHandler.removeMessages(1);
            if (this.mPage != null) {
              this.mPage.onPageTurnFinished(canvas);
            }
            this.mPageTurning = false;
            this.mStepping = false;
            invalidate();
          }
        }
      }  public void startPageTurn()
      {
        if ((this.mPage == null) && (this.mPageId != -1)) {
          this.mPage = ((Page)findViewById(this.mPageId));
        }
        if (this.mPage == null) {
          return;
        }
        this.mPage.setPageTurner(this);    Drawable d = this.mPage.getPageBackground();
        if (d != null) {
          this.mPageBackground = d;
        }
        d = this.mPage.getBackPage();
        if (d != null) {
          this.mBackPage = d;
        }    int corner = this.mPage.getCorner();
        if (corner != -1) {
          this.mCorner = corner;
        }    this.mPageTurning = true;
        this.mTimeStep = 0;
        this.mDrawnTimeStep = -1;
        Message msg = this.mHandler.obtainMessage(1);
        this.mNextTime = (SystemClock.uptimeMillis() + 100L);
        this.mHandler.sendMessageAtTime(msg, this.mNextTime);
      }  public void stepPageTurn()
      {
        if (!this.mStepping)
        {
          this.mStepping = true;
          startPageTurn();
        }
        else {
          Message msg = this.mHandler.obtainMessage(1);
          this.mNextTime = (SystemClock.uptimeMillis() + 10L);
          this.mHandler.sendMessageAtTime(msg, this.mNextTime);
        }
      }  private boolean updateTimeStep()
      {
        if (this.mTimeStep >= 30) {
          return false;
        }
        this.mTimeStep += 1;
        return true;
      }  private boolean computePageTurn()
      {
        if ((this.mDrawnTimeStep == this.mTimeStep) || (this.mTimeStep >= 30)) {
          return false;
        }
        if (this.mPage == null) {
          return false;
        }
        this.mDrawnTimeStep = this.mTimeStep;
        View child = this.mPage.getChildAt(0);
        child.getDrawingRect(this.mChildRect);
        this.mOuterOffsetX = (child.getWindowLeft() - getWindowLeft());
        this.mOuterOffsetY = (child.getWindowTop() - getWindowTop());    float width = this.mChildRect.right;
        float height = this.mChildRect.bottom;
        this.mPivotX = (this.mTimeStep / 30.0F * width);
        this.mForegroundPath = new Path();
        this.mBackPagePath = new Path();
        this.mBackgroundPath = new Path();
        float slope = width / (this.mPivotX - width);
        float y = this.mPivotX * slope;    this.mPageTurnCorner.x = 0.0F;
        this.mPageTurnCorner.y = height;
        this.mOppositeCorner.x = width;
        this.mOppositeCorner.y = 0.0F;
        float x0 = this.mPivotX;
        float cornerIntersect = height * width / (height + width);
        if ((this.mCorner & 0x1) != 0) {
          this.mPageTurnCorner.x = width;
          this.mOppositeCorner.x = 0.0F;
          x0 = width - x0;
        }
        if ((this.mCorner & 0x2) != 0) {
          this.mPageTurnCorner.y = 0.0F;
          this.mOppositeCorner.y = height;
        }    this.mPageDim.x = width;
        this.mPageDim.y = height;
        float page_slope;
        float page_slope;
        if (this.mPivotX <= cornerIntersect)
        {
          page_slope = firstHalfPageTurn(this.mPageDim, this.mPageTurnCorner, this.mOppositeCorner, x0, slope, y);
        }
        else
        {
          page_slope = secondHalfPageTurn(this.mPageDim, this.mPageTurnCorner, this.mOppositeCorner, x0, slope, y);
        }    this.mRotation = (float)Math.atan(page_slope);    this.mRotation = (float)(-this.mRotation * 180.0D / 3.141592653589793D);    return true;
      }
      

  7.   

    第二部分private float firstHalfPageTurn(PointF pageDim, PointF pageTurnCorner, PointF oppositeCorner, float xPivot, float slope, float y)
      {
        float width = pageDim.x;
        float height = pageDim.y;
        View child = this.mPage.getChildAt(0);
        int innerOffsetX = child.getWindowLeft() - this.mPage.getWindowLeft();
        int innerOffsetY = child.getWindowTop() - this.mPage.getWindowTop();    float y1 = height + y;    float x2 = (float)(2.0D * y / (slope + 1.0D / slope));
        float y2 = height + x2 / slope;
        float page_slope = (height - y2) / (x2 - this.mPivotX);
        if ((this.mCorner & 0x1) != 0) {
          x2 = width - x2;
          page_slope = -page_slope;
        }
        if ((this.mCorner & 0x2) != 0) {
          y1 = height - y1;
          y2 = height - y2;
          page_slope = -page_slope;
        }    float x0 = xPivot;
        float x1 = pageTurnCorner.x;    this.mForegroundPath.moveTo(innerOffsetX + x1, innerOffsetY + y1);
        this.mForegroundPath.lineTo(innerOffsetX + pageTurnCorner.x, innerOffsetY + oppositeCorner.y);    this.mForegroundPath.lineTo(innerOffsetX + oppositeCorner.x, innerOffsetY + oppositeCorner.y);    this.mForegroundPath.lineTo(innerOffsetX + oppositeCorner.x, innerOffsetY + pageTurnCorner.y);    this.mForegroundPath.lineTo(innerOffsetX + x0, innerOffsetY + pageTurnCorner.y);    this.mForegroundPath.lineTo(innerOffsetX + x2, innerOffsetY + y2);
        this.mForegroundPath.lineTo(innerOffsetX + x1, innerOffsetY + y1);    this.mBackPagePath.moveTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);
        this.mBackPagePath.lineTo(this.mOuterOffsetX + x2, this.mOuterOffsetY + y2);
        this.mBackPagePath.lineTo(this.mOuterOffsetX + x0, this.mOuterOffsetY + pageTurnCorner.y);    this.mBackPagePath.lineTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);    this.mBackgroundPath.moveTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);
        this.mBackgroundPath.lineTo(this.mOuterOffsetX + x0, this.mOuterOffsetY + pageTurnCorner.y);    this.mBackgroundPath.lineTo(this.mOuterOffsetX + pageTurnCorner.x, this.mOuterOffsetY + pageTurnCorner.y);    this.mBackgroundPath.lineTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);    return page_slope;
      }  private float secondHalfPageTurn(PointF pageDim, PointF pageTurnCorner, PointF oppositeCorner, float xPivot, float slope, float y)
      {
        float width = pageDim.x;
        float height = pageDim.y;
        View child = this.mPage.getChildAt(0);
        int xOffset = child.getWindowLeft() - this.mPage.getWindowLeft();
        int yOffset = child.getWindowTop() - this.mPage.getWindowTop();    float y1 = 0.0F;
        float x1 = width - (height + width) * (width - this.mPivotX) / width;    float x3 = (float)(2.0D * y / (slope + 1.0D / slope));
        float y3 = height + x3 / slope;
        float page_slope = (height - y3) / (x3 - this.mPivotX);
        float b = height - x1 * page_slope;
        float x2 = (float)((-y - b) / (page_slope + 1.0D / page_slope));
        float y2 = (x1 - x2) * page_slope;    if ((this.mCorner & 0x1) != 0) {
          x1 = width - x1;
          x2 = width - x2;
          x3 = width - x3;
          page_slope = -page_slope;
        }
        if ((this.mCorner & 0x2) != 0) {
          y1 = height - y1;
          y2 = height - y2;
          y3 = height - y3;
          page_slope = -page_slope;
        }    float x0 = xPivot;    this.mForegroundPath.moveTo(xOffset + x1, yOffset + y1);
        this.mForegroundPath.lineTo(xOffset + oppositeCorner.x, yOffset + oppositeCorner.y);    this.mForegroundPath.lineTo(xOffset + oppositeCorner.x, yOffset + pageTurnCorner.y);    this.mForegroundPath.lineTo(xOffset + x0, yOffset + pageTurnCorner.y);
        this.mForegroundPath.lineTo(xOffset + x1, yOffset + y1);    this.mBackPagePath.moveTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);
        this.mBackPagePath.lineTo(this.mOuterOffsetX + x2, this.mOuterOffsetY + y2);
        this.mBackPagePath.lineTo(this.mOuterOffsetX + x3, this.mOuterOffsetY + y3);
        this.mBackPagePath.lineTo(this.mOuterOffsetX + x0, this.mOuterOffsetY + pageTurnCorner.y);    this.mBackPagePath.lineTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);    this.mBackgroundPath.moveTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);
        this.mBackgroundPath.lineTo(this.mOuterOffsetX + x0, this.mOuterOffsetY + pageTurnCorner.y);    this.mBackgroundPath.lineTo(this.mOuterOffsetX + pageTurnCorner.x, this.mOuterOffsetY + pageTurnCorner.y);    this.mBackgroundPath.lineTo(this.mOuterOffsetX + pageTurnCorner.x, this.mOuterOffsetY + oppositeCorner.y);    this.mBackgroundPath.lineTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);    return page_slope;
      }  private void drawBackground(Canvas canvas)
      {
        canvas.save();
        canvas.clipPath(this.mBackgroundPath, Canvas.ClipMode.INTERSECT);
        canvas.translate(this.mOuterOffsetX, this.mOuterOffsetY);
        if (this.mPageBackground != null) {
          this.mPageBackground.setBounds(0, 0, this.mChildRect.right, this.mChildRect.bottom);      this.mPageBackground.draw(canvas);
        }
        if (this.mPage != null) {
          this.mPage.drawBackground(canvas);
        }
        canvas.restore();
      }  private void drawBackPage(Canvas canvas)
      {
        float width = this.mChildRect.right;
        float height = this.mChildRect.bottom;    canvas.save();
        canvas.clipPath(this.mBackPagePath, Canvas.ClipMode.INTERSECT);
        float xShift = 2.0F * this.mPivotX - width;
        float xRotate = width - this.mPivotX;
        float yRotate = height;
        if ((this.mCorner & 0x1) != 0) {
          xShift = width - 2.0F * this.mPivotX;
          xRotate = this.mPivotX;
        }
        if ((this.mCorner & 0x2) != 0) {
          yRotate = 0.0F;
        }
        canvas.translate(this.mOuterOffsetX + xShift, this.mOuterOffsetY);
        canvas.rotate(this.mRotation, xRotate, yRotate);
        if (this.mBackPage != null) {
          this.mBackPage.setBounds(0, 0, this.mChildRect.right, this.mChildRect.bottom);
          this.mBackPage.draw(canvas);
        }
        if (this.mPage != null) {
          this.mPage.drawBackPage(canvas);
        }
        canvas.restore();
      }
    }
      

  8.   

    这个东西我没弄过
    只能给你老版本sdk里面的pageTunner和相关的java源码 你可以直接用来试试看 应该是可以实现的
    如果你要源文件我可以邮箱给你
      

  9.   

    楼主给我发一份啊,[email protected]
    多谢.
      

  10.   

    铜球 
    邮箱:[email protected]
      

  11.   

    这里有standatw放的m3的代码
    http://download.csdn.net/source/2668990多谢了
      

  12.   

    楼主请给我发一份,多谢.
    [email protected]
      

  13.   

    我修改了下源码,以下是可一适用于android2.2-level 8的代码Page.java
    import android.content.Context;
    import android.content.res.TypedArray;
    import android.graphics.Canvas;
    import android.graphics.Path;
    import android.graphics.Region;
    import android.graphics.drawable.Drawable;
    import android.util.AttributeSet;
    import android.widget.RelativeLayout;
     
    public class Page extends RelativeLayout {
    public static final int CORNER_BOTTOM_LEFT = 0;
    public static final int CORNER_BOTTOM_RIGHT = 1;
    public static final int CORNER_TOP_LEFT = 2;
    public static final int CORNER_TOP_RIGHT = 3;
    private Path mClipPath;
    private PageTurner mPageTurner;
    private Callback mCallback;
    private int mCorner;
    private Drawable mBackPage;
    private Drawable mPageBackground;
     
    public Page(Context context) {
    super(context);
    }
     
    public Page(Context context, AttributeSet attrs ) {
    super(context, attrs );
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PageTurner);
     
    this.mBackPage = a.getDrawable(1);
    this.mPageBackground = a.getDrawable(0);
     
    this.mCorner = a.getInt(2, -1);
    }
     
    void setPageTurner(PageTurner pageTurner) {
    this.mPageTurner = pageTurner;
    } void setClipPath(Path clipPath) {
    this.mClipPath = clipPath;
    }
       
    public void setCallback(Callback callback)  {
    this.mCallback = callback;
    }
     
    void drawBackPage(Canvas canvas) {
       if (this.mCallback != null)
       this.mCallback.onDrawBackPage(canvas);
    }
       
    void drawBackground(Canvas canvas) {
    if (this.mCallback != null)
    this.mCallback.onDrawBackground(canvas);
    }
     
    public void startPageTurn() {
    if (this.mPageTurner != null)
    this.mPageTurner.startPageTurn();
    }
     
    void onPageTurnFinished(Canvas canvas) {
    this.mCallback.onPageTurnFinished(canvas);
    this.mClipPath = null;
    } protected void dispatchDraw(Canvas canvas) {
    if (this.mClipPath != null) {
    canvas.save();
    canvas.clipPath(this.mClipPath, Region.Op.INTERSECT);
    }
    super.dispatchDraw(canvas);
    if (this.mClipPath != null)
    canvas.restore();
    }
     
    public void setCorner(int corner) {
    this.mCorner = corner;
    }
     
    public int getCorner() {
    return this.mCorner;
    } public void setBackPage(Drawable backPage) {
    this.mBackPage = backPage;
    } public Drawable getBackPage() {
    return this.mBackPage;
    }
     
    public void setPageBackground(Drawable background) {
    this.mPageBackground = background;
    }
     
    public Drawable getPageBackground() {
    return this.mPageBackground;
    } public static abstract class Callback {
    public void onDrawBackPage(Canvas canvas) {}
    public void onDrawBackground(Canvas canvas) {}
    public void onPageTurnFinished(Canvas canvas) {}
    }
    }
      

  14.   

    PageTurner.java上半部分import android.content.Context;
    import android.content.res.TypedArray;
    import android.graphics.Canvas;
    import android.graphics.Path;
    import android.graphics.PointF;
    import android.graphics.Rect;
    import android.graphics.Region;
    import android.graphics.drawable.Drawable;
    import android.os.Handler;
    import android.os.Message;
    import android.os.SystemClock;
    import android.util.AttributeSet;
    import android.util.Log;
    import android.view.View;
    import android.widget.RelativeLayout;public class PageTurner extends RelativeLayout{

      private static final int CORNER_RIGHT_MASK = 1;
      private static final int CORNER_TOP_MASK = 2;
      public static final int CORNER_BOTTOM_LEFT = 0;
      public static final int CORNER_BOTTOM_RIGHT = 1;
      public static final int CORNER_TOP_LEFT = 2;
      public static final int CORNER_TOP_RIGHT = 3;
      private static final int INVALIDATE = 1;
      private static final int INITIAL_TIME_DELAY = 100;
      private static final int TIME_DELAY = 10;
      private static final int TIME_STEPS = 30;
      private boolean mPageTurning;
      private boolean mStepping;
      private long mNextTime;
      private int mTimeStep;
      private int mDrawnTimeStep;
      private int mCorner;
      private Drawable mBackPage;
      private Drawable mPageBackground;
      private Path mForegroundPath;
      private Path mBackPagePath;
      private Path mBackgroundPath;
      private float mRotation;
      private Rect mChildRect = new Rect();
      private int mOuterOffsetX;
      private int mOuterOffsetY;
      private float mPivotX;
      private int mPageId;
      private Page mPage;
      private PointF mPageTurnCorner = new PointF();
      private PointF mOppositeCorner = new PointF();
      private PointF mPageDim = new PointF();   private final Handler mHandler = new Handler() {
      public void handleMessage(Message msg) {
      if (msg.what != 1) { return; }
      PageTurner.this.invalidate();
      if (PageTurner.this.mStepping) { return; }
      msg = obtainMessage(1);
      long current = SystemClock.uptimeMillis();
      if (PageTurner.this.mNextTime < current) {
      //PageTurner.access$102(PageTurner.this, current + 10L);
      }
      sendMessageAtTime(msg, PageTurner.this.mNextTime);
      //PageTurner.access$114(PageTurner.this, 10L);
      }
      };   public PageTurner(Context context) { 
      super(context);
      }   public PageTurner(Context context, AttributeSet attrs) {
      super(context, attrs);
      
      TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PageTurner);
      
      this.mBackPage = a.getDrawable(1);
      this.mPageBackground = a.getDrawable(0);

      this.mPageId = a.getResourceId(3, -1);

      this.mCorner = a.getInt(2, 0);
      }   protected void onFinishInflate() {
      super.onFinishInflate();
      if (this.mPageId != -1) {
      this.mPage = ((Page)findViewById(this.mPageId));
      if (this.mPage != null)
      this.mPage.setPageTurner(this);
      }
      }   public void setPageId(int pageId) {
      this.mPageId = pageId;
      this.mPage = ((Page)findViewById(this.mPageId));
      if (this.mPage != null)
      this.mPage.setPageTurner(this);
      }   public int getPageId() {
      return this.mPageId;
      }   public void setPage(Page page) {
      this.mPage = page;
      }   public Page getPage() {
      return this.mPage;
      }   public void setCorner(int corner) {
      this.mCorner = corner;
      }   public int getCorner() {
      return this.mCorner;
      }   protected void dispatchDraw(Canvas canvas) {
      if ((this.mPageTurning) && (this.mPage != null) && (computePageTurn())) {
      this.mPage.setClipPath(this.mForegroundPath);
      }   super.dispatchDraw(canvas);   if (this.mPageTurning) {
      drawBackground(canvas);
      drawBackPage(canvas);   if (!updateTimeStep()) {
      this.mHandler.removeMessages(1);
      if (this.mPage != null) {
      this.mPage.onPageTurnFinished(canvas);
      }
      this.mPageTurning = false;
      this.mStepping = false;
      invalidate();
      }
      }
      }   public void startPageTurn() {
      if ((this.mPage == null) && (this.mPageId != -1)) {
      this.mPage = ((Page)findViewById(this.mPageId));
      }
      if (this.mPage == null) {
      return;
      }
      this.mPage.setPageTurner(this);
      Drawable d = this.mPage.getPageBackground();
      if (d != null) {
      this.mPageBackground = d;
      }
      
      d = this.mPage.getBackPage();
      if (d != null) {
      this.mBackPage = d;
      }   int corner = this.mPage.getCorner();
      if (corner != -1) {
      this.mCorner = corner;
      }   this.mPageTurning = true;
      this.mTimeStep = 0;
      this.mDrawnTimeStep = -1;
      Message msg = this.mHandler.obtainMessage(1);
      this.mNextTime = (SystemClock.uptimeMillis() + 100L);
      this.mHandler.sendMessageAtTime(msg, this.mNextTime);
      }   public void stepPageTurn() {
      if (!this.mStepping) {
      this.mStepping = true;
      startPageTurn();
      } else {
      Message msg = this.mHandler.obtainMessage(1);
      this.mNextTime = (SystemClock.uptimeMillis() + 10L);
      this.mHandler.sendMessageAtTime(msg, this.mNextTime);
      }
      }   private boolean updateTimeStep() {
      if (this.mTimeStep >= 30) {
      return false;
      }
      this.mTimeStep += 1;
      return true;
      }   private boolean computePageTurn() {
      if ((this.mDrawnTimeStep == this.mTimeStep) || (this.mTimeStep >= 30)) {
      return false;
      }
      if (this.mPage == null) {
      return false;
      }
      this.mDrawnTimeStep = this.mTimeStep;
      View child = this.mPage.getChildAt(0);
      child.getDrawingRect(this.mChildRect);
      this.mOuterOffsetX = (child.getLeft() - getLeft());
      this.mOuterOffsetY = (child.getTop() - getTop());   float width = this.mChildRect.right;
      float height = this.mChildRect.bottom;
      this.mPivotX = (this.mTimeStep / 30.0F * width);
      this.mForegroundPath = new Path();
      this.mBackPagePath = new Path();
      this.mBackgroundPath = new Path();
      float slope = width / (this.mPivotX - width);
      float y = this.mPivotX * slope;   this.mPageTurnCorner.x = 0.0F;
      this.mPageTurnCorner.y = height;
      this.mOppositeCorner.x = width;
      this.mOppositeCorner.y = 0.0F;
      float x0 = this.mPivotX;
      float cornerIntersect = height * width / (height + width);
      if ((this.mCorner & 0x1) != 0) {
      this.mPageTurnCorner.x = width;
      this.mOppositeCorner.x = 0.0F;
      x0 = width - x0;
      }
      
      if ((this.mCorner & 0x2) != 0) {
      this.mPageTurnCorner.y = 0.0F;
      this.mOppositeCorner.y = height;
      }   this.mPageDim.x = width;
      this.mPageDim.y = height;
      float page_slope;
      
      if (this.mPivotX <= cornerIntersect) {
      page_slope = firstHalfPageTurn(this.mPageDim, this.mPageTurnCorner, this.mOppositeCorner, x0, slope, y);
      } else {
      page_slope = secondHalfPageTurn(this.mPageDim, this.mPageTurnCorner, this.mOppositeCorner, x0, slope, y);
      }   this.mRotation = (float)Math.atan(page_slope);   this.mRotation = (float)(-this.mRotation * 180.0D / 3.141592653589793D);   return true;
      }
      

  15.   

    PageTurner.java下半部分private float firstHalfPageTurn(PointF pageDim, PointF pageTurnCorner, PointF oppositeCorner, float xPivot, float slope, float y) {
      float width = pageDim.x;
      float height = pageDim.y;
      View child = this.mPage.getChildAt(0);
      int innerOffsetX = child.getLeft() - this.mPage.getLeft();
      int innerOffsetY = child.getTop() - this.mPage.getTop();   float y1 = height + y;   float x2 = (float)(2.0D * y / (slope + 1.0D / slope));
      float y2 = height + x2 / slope;
      float page_slope = (height - y2) / (x2 - this.mPivotX);
      if ((this.mCorner & 0x1) != 0) {
      x2 = width - x2;
      page_slope = -page_slope;
      }
      if ((this.mCorner & 0x2) != 0) {
      y1 = height - y1;
      y2 = height - y2;
      page_slope = -page_slope;
      }   float x0 = xPivot;
      float x1 = pageTurnCorner.x;   this.mForegroundPath.moveTo(innerOffsetX + x1, innerOffsetY + y1);
      this.mForegroundPath.lineTo(innerOffsetX + pageTurnCorner.x, innerOffsetY + oppositeCorner.y);   this.mForegroundPath.lineTo(innerOffsetX + oppositeCorner.x, innerOffsetY + oppositeCorner.y);   this.mForegroundPath.lineTo(innerOffsetX + oppositeCorner.x, innerOffsetY + pageTurnCorner.y);   this.mForegroundPath.lineTo(innerOffsetX + x0, innerOffsetY + pageTurnCorner.y);   this.mForegroundPath.lineTo(innerOffsetX + x2, innerOffsetY + y2);
      this.mForegroundPath.lineTo(innerOffsetX + x1, innerOffsetY + y1);   this.mBackPagePath.moveTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);
      this.mBackPagePath.lineTo(this.mOuterOffsetX + x2, this.mOuterOffsetY + y2);
      this.mBackPagePath.lineTo(this.mOuterOffsetX + x0, this.mOuterOffsetY + pageTurnCorner.y);   this.mBackPagePath.lineTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);   this.mBackgroundPath.moveTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);
      this.mBackgroundPath.lineTo(this.mOuterOffsetX + x0, this.mOuterOffsetY + pageTurnCorner.y);   this.mBackgroundPath.lineTo(this.mOuterOffsetX + pageTurnCorner.x, this.mOuterOffsetY + pageTurnCorner.y);   this.mBackgroundPath.lineTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);   return page_slope;
      }   private float secondHalfPageTurn(PointF pageDim, PointF pageTurnCorner, PointF oppositeCorner, float xPivot, float slope, float y) {
      float width = pageDim.x;
      float height = pageDim.y;
      View child = this.mPage.getChildAt(0);
      int xOffset = child.getLeft() - this.mPage.getLeft();
      int yOffset = child.getTop() - this.mPage.getTop();   float y1 = 0.0F;
      float x1 = width - (height + width) * (width - this.mPivotX) / width;   float x3 = (float)(2.0D * y / (slope + 1.0D / slope));
      float y3 = height + x3 / slope;
      float page_slope = (height - y3) / (x3 - this.mPivotX);
      float b = height - x1 * page_slope;
      float x2 = (float)((-y - b) / (page_slope + 1.0D / page_slope));
      float y2 = (x1 - x2) * page_slope;   if ((this.mCorner & 0x1) != 0) {
      x1 = width - x1;
      x2 = width - x2;
      x3 = width - x3;
      page_slope = -page_slope;
      }
      if ((this.mCorner & 0x2) != 0) {
      y1 = height - y1;
      y2 = height - y2;
      y3 = height - y3;
      page_slope = -page_slope;
      }   float x0 = xPivot;   this.mForegroundPath.moveTo(xOffset + x1, yOffset + y1);
      this.mForegroundPath.lineTo(xOffset + oppositeCorner.x, yOffset + oppositeCorner.y);   this.mForegroundPath.lineTo(xOffset + oppositeCorner.x, yOffset + pageTurnCorner.y);   this.mForegroundPath.lineTo(xOffset + x0, yOffset + pageTurnCorner.y);
      this.mForegroundPath.lineTo(xOffset + x1, yOffset + y1);   this.mBackPagePath.moveTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);
      this.mBackPagePath.lineTo(this.mOuterOffsetX + x2, this.mOuterOffsetY + y2);
      this.mBackPagePath.lineTo(this.mOuterOffsetX + x3, this.mOuterOffsetY + y3);
      this.mBackPagePath.lineTo(this.mOuterOffsetX + x0, this.mOuterOffsetY + pageTurnCorner.y);   this.mBackPagePath.lineTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);   this.mBackgroundPath.moveTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);
      this.mBackgroundPath.lineTo(this.mOuterOffsetX + x0, this.mOuterOffsetY + pageTurnCorner.y);   this.mBackgroundPath.lineTo(this.mOuterOffsetX + pageTurnCorner.x, this.mOuterOffsetY + pageTurnCorner.y);   this.mBackgroundPath.lineTo(this.mOuterOffsetX + pageTurnCorner.x, this.mOuterOffsetY + oppositeCorner.y);   this.mBackgroundPath.lineTo(this.mOuterOffsetX + x1, this.mOuterOffsetY + y1);   return page_slope;
      }   private void drawBackground(Canvas canvas) {
      canvas.save();
      canvas.clipPath(this.mBackgroundPath, Region.Op.INTERSECT);
      canvas.translate(this.mOuterOffsetX, this.mOuterOffsetY);
      if (this.mPageBackground != null) {
      this.mPageBackground.setBounds(0, 0, this.mChildRect.right, this.mChildRect.bottom);   this.mPageBackground.draw(canvas);
      }
      if (this.mPage != null) {
      this.mPage.drawBackground(canvas);
      }
      canvas.restore();
      }   private void drawBackPage(Canvas canvas) {
      float width = this.mChildRect.right;
      float height = this.mChildRect.bottom;   canvas.save();
      canvas.clipPath(this.mBackPagePath, Region.Op.INTERSECT);
      float xShift = 2.0F * this.mPivotX - width;
      float xRotate = width - this.mPivotX;
      float yRotate = height;
      if ((this.mCorner & 0x1) != 0) {
      xShift = width - 2.0F * this.mPivotX;
      xRotate = this.mPivotX;
      }
      if ((this.mCorner & 0x2) != 0) {
      yRotate = 0.0F;
      }
      canvas.translate(this.mOuterOffsetX + xShift, this.mOuterOffsetY);
      canvas.rotate(this.mRotation, xRotate, yRotate);
      if (this.mBackPage != null) {
      this.mBackPage.setBounds(0, 0, this.mChildRect.right, this.mChildRect.bottom);
      this.mBackPage.draw(canvas);
      }
      if (this.mPage != null) {
      this.mPage.drawBackPage(canvas);
      }
      canvas.restore();
      }
    }
    但是在PageTurner中有个问题,if (PageTurner.this.mNextTime < current) {
        //PageTurner.access$102(PageTurner.this, current + 10L);
    }
    sendMessageAtTime(msg, PageTurner.this.mNextTime);
    //PageTurner.access$114(PageTurner.this, 10L);
    注释这段的acess$102和access$114是何意??
      

  16.   

    顶~~~
    找到一个android手势翻页效果的文章,有源代码的详细说明,并有下载。
    http://wxmijl.blog.163.com/blog/static/13245928201062744245658/
      

  17.   

    CSDN上面不能上传附件么?要是能当附件上传供大家下载就好了。
      

  18.   


    这个是滑动翻页,非PageTurner的模拟真实效果翻页
      

  19.   

    资源发布在以下地址:
    http://download.csdn.net/source/2681832
      

  20.   

    R.styleable.PageTurner这个常量值,没法在1.6 or higher的版本上找到呀
      

  21.   

    standatw 发我的代码就是上面贴的代码,还是需要继续研究啊!!!
      

  22.   

    我这里有一个翻页很类似iBook的翻页的apk,还有3D,card等效果,做的不错,需要的拿去反编译研究一下吧,没有源码
    http://download.csdn.net/source/2691661
      

  23.   

    怎么应用page.java, pageturner.java? 
    thanks
      

  24.   

    这一段要改成这样,要不就不能有效果 
     if (PageTurner.this.mNextTime < current) {
       PageTurner.this.mNextTime= current + 10L;
      }
      sendMessageAtTime(msg, PageTurner.this.mNextTime);
       PageTurner.this.mNextTime+= 10L;
      

  25.   

    如果是简单的滑动翻页那可以看看日历的源码。也可以看sdk。如果要做成3d的会卷页的那种效果,估计要自己写算法了。
      

  26.   

    thanks 正需要这些呢 
      

  27.   

    翻页效果,最好用jQuery写,之前有这个源码的  找不到了。