世界! 我使用Harism Page Curl在我的项目中实现页面卷曲所有事情都可以,但是卷曲的方向。 我在我的应用程序中使用阿拉伯语,因此卷曲必须是从左到右(阿拉伯语书籍)。
这个图书馆提供的是从右到左卷曲(英文书籍)。
所以我尝试了以下但没有成功:
更改CurlView类中的参数。 如下图所示:
公共类CurlView扩展GLSurfaceView实现了View.OnTouchListener, CurlRenderer.Observer {
// Shows one page at the center of view.
public static final int SHOW_ONE_PAGE = 1;
// Shows two pages side by side.
public static final int SHOW_TWO_PAGES = 2;
// Curl state. We are flipping none, left or right page.
private static final int CURL_LEFT = 1;
private static final int CURL_NONE = 0;
private static final int CURL_RIGHT = 2;
// Constants for mAnimationTargetEvent.
private static final int SET_CURL_TO_LEFT = 1;
private static final int SET_CURL_TO_RIGHT = 2;
private boolean mAllowLastPageCurl = true;
private boolean mAnimate = false;
private long mAnimationDurationTime = 300;
private PointF mAnimationSource = new PointF();
private long mAnimationStartTime;
private PointF mAnimationTarget = new PointF();
private int mAnimationTargetEvent;
private PointF mCurlDir = new PointF();
private PointF mCurlPos = new PointF();
private int mCurlState = CURL_NONE;
// Current bitmap index. This is always showed as front of right page.
private int mCurrentIndex = 0;
// Start position for dragging.
private PointF mDragStartPos = new PointF();
private boolean mEnableTouchPressure = false;
// Bitmap size. These are updated from renderer once it's initialized.
private int mPageBitmapHeight = -1;
private int mPageBitmapWidth = -1;
// Page meshes. Left and right meshes are 'static' while curl is used to
// show page flipping.
private CurlMesh mPageCurl;
private CurlMesh mPageLeft;
private PageProvider mPageProvider;
private CurlMesh mPageRight;
private PointerPosition mPointerPos = new PointerPosition();
private CurlRenderer mRenderer;
private boolean mRenderLeftPage = true;
private SizeChangedObserver mSizeChangedObserver;
// One page is the default.
private int mViewMode = SHOW_ONE_PAGE;`
和
@Override
public int getPageCount() {
return mBitmapIds.length;
}
public Bitmap loadBitmap(int width, int height, int index) {
tracker.send(new HitBuilders.EventBuilder()
.setCategory("UX")
.setAction("click")
.setLabel("submit")
.build());
Bitmap b = Bitmap.createBitmap(width, height,
Bitmap.Config.ARGB_8888);
b.eraseColor(Color.WHITE);
Canvas c = new Canvas(b);
Drawable d = getResources().getDrawable(mBitmapIds[index]);
int margin = 0;
int border = 0;
Rect r = new Rect(margin, margin, width, height);
int imageWidth = r.width() - (border);
assert d != null;
int imageHeight = imageWidth * d.getIntrinsicHeight()
/ d.getIntrinsicWidth();
if (imageHeight > r.height() - (border)) {
imageHeight = r.height() - (border);
imageWidth = imageHeight * d.getIntrinsicWidth()
/ d.getIntrinsicHeight();
}
r.left += ((r.width() - imageWidth));
r.right = r.left + imageWidth + border;
r.top += r.top;
Paint p = new Paint();
p.setColor(0xFFC0C0C0);
c.drawRect(r, p);
r.left += border;
r.right -= border;
r.top += border;
r.bottom -= border;
d.setBounds(r);
d.draw(c);
return b;
}
@Override
public void updatePage(CurlPage page, int width, int height, int index) {
if (index == i) {
Bitmap back = loadBitmap(width, height, index);
page.setTexture(back, CurlPage.SIDE_BOTH);
index++;
i++;
} else {
Bitmap back = loadBitmap(width, height, index);
page.setTexture(back, CurlPage.SIDE_BOTH);
}
}