Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android page curl effect on layout/s

Tags:

android

I am working on a project where I have to curl entire view/layout where I've textview, edittexts, buttons, etc. The task is that I have to curl the entire layout along with those buttons and all. I am not able to understand how to do it in order to curl entire layout instead of just images.

Please help

like image 565
Me-an-Droid Avatar asked Nov 18 '11 09:11

Me-an-Droid


1 Answers

I have done so using the harism github project. All you need to do is grab a bitmap image of the layout by inflating it. Here is the code which replaces the loadBitmap function in the CurlActivity.java.

// Bitmap resources.
private int[] mBitmapIds = { R.layout.infopage0,R.layout.infopage1,
                             R.layout.infopage2, R.layout.infopage3 };

    @Override
    public int getPageCount() {
        return 4;
    }

    private Bitmap loadBitmap(int width, int height, int index) {
        LayoutInflater inflater = 
              (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View v = inflater.inflate(mBitmapIds[index],null);
        v.measure(
                  MeasureSpec.makeMeasureSpec(width,MeasureSpec.EXACTLY),
                  MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
            v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
            Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight()
                    ,Bitmap.Config.ARGB_8888);
            Canvas c = new Canvas(b);
            v.draw(c);          
        return b;
    }

The array mBitmapIds is now an array of the xml layout id's.

like image 182
Locutus Avatar answered Sep 29 '22 01:09

Locutus