8

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

Me-an-Droid
  • 244
  • 6
  • 12
  • please define how one does "curl" a layout – Jan Dragsbaek Nov 18 '11 at 09:58
  • Sorry, if I am not able to make my question clear. I want to apply curl page effect on layout instead of image so that when I curl the page, textviews, buttons, etc curl along the layout. – Me-an-Droid Nov 18 '11 at 10:36
  • There are quite many questions around Stackoverflow about page curling, e.g. [this one](http://stackoverflow.com/questions/3912849/implement-page-curl-on-android/). – 87element Nov 18 '11 at 10:43
  • @Me-an-Droid is it possible to give the dynamic layout paths in private int[] mBitmapIds? – RaMeSh Jun 15 '15 at 06:02
  • HI @Me-an-Droid, did you find any solution for the curl effect for dynamic layouts? – Abdulfatah Nasrat Jul 12 '22 at 12:34

2 Answers2

8

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.

Tiago Almeida
  • 14,081
  • 3
  • 67
  • 82
Locutus
  • 81
  • 1
  • 2
0

I have not worked over Curl effect but I have found a project for you which may help you.

https://github.com/harism/android_page_curl/

Vineet Shukla
  • 23,865
  • 10
  • 55
  • 63
  • 1
    Hi vineet. Thanks for the sample link. I've already used this example to apply curl effect on images but I am not getting how to apply the same on layout. – Me-an-Droid Nov 18 '11 at 10:38