【问题标题】:Page curl by harism, text is shown not normal on two page modeharism 卷页,两页模式下文字显示不正常
【发布时间】:2014-03-02 12:29:32
【问题描述】:

我正在使用 Harism https://github.com/harism/android_page_curl‎的翻页动画。我正在通过绘制文本而不是图像来测试这个项目。单页模式时,显示正常文字:

但是,当它是两页模式(横向)时,结果如下:

问题是左侧的文本状态。有一个方法 onSizeChanged 可以控制屏幕方向和改变页面模式:

 @Override
    public void onSizeChanged(int w, int h) {
            if (w > h) { 
                mCurlView.setViewMode(CurlView.SHOW_TWO_PAGES);
               mCurlView.setMargins(.1f, .05f, .1f, .05f);
            } else { 
                mCurlView.setViewMode(CurlView.SHOW_ONE_PAGE);
                mCurlView.setMargins(.1f, .1f, .1f, .1f);
    }
    }

更改模式后,页面矩形将被更新

private void updatePageRects() {
      if (mViewRect.width() == 0 || mViewRect.height() == 0) {
          return;
      } else if (mViewMode == SHOW_ONE_PAGE) {
          mPageRectRight.set(mViewRect);
          mPageRectRight.left += mViewRect.width() * mMargins.left;
          mPageRectRight.right -= mViewRect.width() * mMargins.right;
          mPageRectRight.top += mViewRect.height() * mMargins.top;
          mPageRectRight.bottom -= mViewRect.height() * mMargins.bottom;

          mPageRectLeft.set(mPageRectRight);
          mPageRectLeft.offset(-mPageRectRight.width(), 0);

          int bitmapW = (int) ((mPageRectRight.width() * mViewportWidth) / mViewRect
                  .width());
          int bitmapH = (int) ((mPageRectRight.height() * mViewportHeight) / mViewRect
                  .height());
          mObserver.onPageSizeChanged(bitmapW, bitmapH);
      } else if (mViewMode == SHOW_TWO_PAGES) {
          mPageRectRight.set(mViewRect);
          mPageRectRight.left += mViewRect.width() * mMargins.left;
          mPageRectRight.right -= mViewRect.width() * mMargins.right;
          mPageRectRight.top += mViewRect.height() * mMargins.top;
          mPageRectRight.bottom -= mViewRect.height() * mMargins.bottom;

          mPageRectLeft.set(mPageRectRight);
          mPageRectLeft.right = (mPageRectLeft.right + mPageRectLeft.left) / 2;
          mPageRectRight.left = mPageRectLeft.right;

          int bitmapW = (int) ((mPageRectRight.width() * mViewportWidth) / mViewRect
                  .width());
          int bitmapH = (int) ((mPageRectRight.height() * mViewportHeight) / mViewRect
                  .height());
          mObserver.onPageSizeChanged(bitmapW, bitmapH);
      }
  }

此项目使用 OpenGL/ES 创建。有什么帮助吗?

【问题讨论】:

  • 您的左侧纹理坐标似乎不正确。它可能是 curl 库的另一个功能/错误。一些代码,说明如何更改为两页模式会有所帮助。
  • @猪我更新了我的问题
  • 这似乎很合理。如果在 if(mViewMode == SHOW_TWO_PAGES) 块末尾将 mPageRectLeft.right 替换为 mPageRectLeft.left 会发生什么?
  • 好吧,实际上,更多地研究 curl 的工作原理,这似乎是“正确”的行为,因为左侧页面有时被设置为翻转和不翻转。看来这个库是为了迷惑人而写的。
  • 我们该如何解决这个问题?

标签: android page-curl


【解决方案1】:

这似乎是库中的另一个错误。根据 GitHub cmets,最近更新了有关两页功能的代码。我建议联系作者并请求修复。

【讨论】:

  • 我在这里找到了这个项目的另一个旧版本 github.com/cags12/android_page_curl。左侧页面显示正确。现在,我们应该找出进行了哪些更改,影响了左侧图像的位置错误
  • 太好了,现在你到了某个地方。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-07
  • 2012-08-05
  • 1970-01-01
  • 2012-10-17
相关资源
最近更新 更多