在布局/的Andr​​oid页面卷曲效果 [英] Android page curl effect on layout/s

查看:90
本文介绍了在布局/的Andr​​oid页面卷曲效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个项目,我不得不蜷缩整个视图/布局,我已经TextView的,edittexts,按钮等的任务是,我有卷曲的整个布局与这些按钮和所有。我无法理解如何做到这一点,以卷曲只是图像的整个布局来代替。

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.

请帮忙

推荐答案

我这样做使用harism github上项目。所有你需要做的是通过膨胀它抓取布局的位图图像。这里是code取代了 loadBitmap 功能 CurlActivity.java

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;
    }

阵列 mBitmapIds 现在的XML布局ID的数组。

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

这篇关于在布局/的Andr​​oid页面卷曲效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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