English 中文(简体)
Android页 Har Har Har ism ism
原标题:Android Page Curl Animation by Harism shows inconsistency in the reverse index count in the getBitmap() method of CurlActivity()?

我在申请时使用了Harism s pages Curl animation,但我一直面临一个小问题,我正在使用getBitmap()的指数值,但当我把页数贴在页数上时,我需要向用户显示页数(例如,使用电话<>Toast.maketext(>)。

任何人都可以帮助我。

预付款。

P.S.:That将是我关于中途停留的第一个问题

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.

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感谢你分享这一美丽的框架!

如今,只是为了补充Harism的反应:

当与杂志、书籍等合作时,我们处理的页数未定。

In the example presented in class CurlActivity, of project Harism-Android-Page-Curl, uses a "Switch" to control the pages. To be able to meet my needs, I had to change the method "updatePage" and then control my magazines more appropriately, regardless of the amount of pages.

我需要根据指数(方法签名本身)和目前的取向装置提出以下概要:

Landscape Orientation ("Side Back" with next page)

索引 Left | Page Right

页: 1

1 D-1, 1 D-1, 1 P-5, 1 P-4, 1 P-3, 1 P-2, 1 GS, 3 NS

页: 1

页: 1

页: 1


<>Portrait Orientation (“Side Back” with same page reflected)

索引

页: 1

页: 1

2 GS

页: 1

4)

......

为了实施这一计划,首先必须改变这一方法:

public int getPageCount() {
        //return 5;

        int pagesCount = 0;

        DisplayMetrics displaymetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
        int wwidth = displaymetrics.widthPixels;
        int hheight = displaymetrics.heightPixels;

        if(wwidth > hheight){
            if((mBitmapIds.length % 2) > 0)
                pagesCount = (mBitmapIds.length / 2) + 1;
            else
                pagesCount = mBitmapIds.length / 2;
        }else{
            pagesCount = mBitmapIds.length;
        }
        return pagesCount;
    }

这将使网页柜台能够归还实际页数。


然后改变更新方法 页: 1

public void updatePage(CurlPage page, int width, int height, int index) {

        DisplayMetrics displaymetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
        int wwidth = displaymetrics.widthPixels;
        int hheight = displaymetrics.heightPixels;

        if(wwidth > hheight){

            System.out.println("case landscape orientation...");
            Bitmap front = loadBitmap(width, height, (index * 2));
            Bitmap back = loadBitmap(width, height, (index * 2) + 1);

            Matrix matrix = new Matrix(); 
            matrix.preScale(-1.0f, 1.0f); 
            Bitmap mirroredBitmap = Bitmap.createBitmap(back, 0, 0, back.getWidth(), back.getHeight(), matrix, false);

            page.setTexture(front, CurlPage.SIDE_FRONT);
            page.setTexture(mirroredBitmap, CurlPage.SIDE_BACK);

        }else{

            System.out.println("case portrait orientation...");
            Bitmap front = loadBitmap(width, height, index);
            Bitmap back = loadBitmap(width, height, index);

            page.setTexture(front, CurlPage.SIDE_FRONT);
            page.setTexture(back, CurlPage.SIDE_BACK);

        }}}

我希望我帮助!

我们再次感谢“Harism”框架!





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签