Harism的Android Page Curl Animation显示CurlActivity()的getBitmap()方法中的反向索引计数不一致吗? [英] Android Page Curl Animation by Harism shows inconsistency in the reverse index count in the getBitmap() method of CurlActivity()?

查看:96
本文介绍了Harism的Android Page Curl Animation显示CurlActivity()的getBitmap()方法中的反向索引计数不一致吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中使用了Harism的Page Curl动画,但是遇到了一个小问题,我在 getBitmap()方法中使用索引Value。 CurlActivity,我需要在每次翻页时向用户显示页码(例如,使用对 Toast.maketext()。show 的调用),这在运行时效果很好从页面0到 pageCount.length ,但是当我从右向左移动页面(即从 pageCount.lenth 设为0),索引值不会持续降低。

I have used Harism's Page Curl animation for my application, but I have been facing a small problem, I am using the index Value in the getBitmap() method of the CurlActivity, I need to show page numbers to the user on every flip of the page(say using a call to Toast.maketext().show), this works fine while going from page 0 to pageCount.length, but when I move page right to left(the pages, i.e. while going the other way from pageCount.lenth to 0) the index values are not consistently reduced.

有人可以帮我吗?

谢谢。

PS:这是我对stackoverflow的第一个问题

P.S.:That would be my first question on stackoverflow

public Bitmap getBitmap(int width, int height, int index) {

        Bitmap b = Bitmap.createBitmap(width, height,Bitmap.Config.ARGB_8888);
        b.eraseColor(0xFFFFFFFF);
        Canvas c = new Canvas(b);

        //this is where index seems to go wrong on reverse counting, I believe
        Log.e("PAGE--", ""+index);
        Toast.makeText(CurlActivity.this, ""+index, Toast.LENGTH_SHORT).show();
        Drawable d = getResources().getDrawable(mBitmapIds[index]);

        int margin = 7;
        int border = 3;

        return b
}


推荐答案

问题是,您确实不能出于尝试实现的目的而依赖于请求的页面索引。您遇到这种情况的原因是,当您向前翻页时,仅请求下一页,在这种情况下,索引似乎就是您所期望的。但是向后更改页面的效果恰好相反,仅请求上一页,并且在这些单独的操作之间的索引之间存在间隙。

Problem is that you really can't rely on requested page index on purpose you try to implement. Reason for the behavior you're facing is that once you flip through pages forward, only 'next page' is requested, in which case index seems to be what you're expecting. But changing pages backwards works the exact opposite, only 'previous page' is requested, and there's a gap within index between these separate operations.

有一个方法CurlView.getCurrentIndex( ),但它会不断设置为右侧显示的页面的索引。它应该为您提供显示实际页码的方法。

There's a method CurlView.getCurrentIndex() though which is constantly set to index of the page being shown on right side. It should give you means for having actual page numbers shown.

这篇关于Harism的Android Page Curl Animation显示CurlActivity()的getBitmap()方法中的反向索引计数不一致吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆