Package android.widget

Examples of android.widget.ImageView


        final int width = metrics.widthPixels;
        final int height = metrics.heightPixels;

        final Bitmap lBmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        final Canvas lCanvas = new Canvas(lBmp);
        final ImageView lImgView = new ImageView(this);

        lImgView.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        lImgView.setImageBitmap(lBmp);
        lImgView.setScaleType(ImageView.ScaleType.CENTER);
        lImgView.setPadding(0, 0, 0, 0);

        final Paint bck = new Paint();
        bck.setARGB(0xff, 0x80, 0x80, 0x80);
        lCanvas.drawRect(0, 0, width, height, bck);

        final Paint p = new Paint();
        p.setARGB(0xff, 0xff, 0x00, 0xff);
 
        mLinearLayout.addView(lImgView);
        setContentView(mLinearLayout);

        lImgView.setOnTouchListener(new OnTouchListener() {

            // start and end coordinates for a single line
            float sx, sy, ex, ey;

            public boolean onTouch(View aView, MotionEvent aME) {

                Rect lRect = new Rect();
                Window lWindow = getWindow();
                lWindow.getDecorView().getWindowVisibleDisplayFrame(lRect);
                int lStatusBarHeight = lRect.top;
                int lContentViewTop =
                        lWindow.findViewById(Window.ID_ANDROID_CONTENT).getTop();
                final int lTitleBarHeight = lContentViewTop - lStatusBarHeight;

                int lAction = aME.getAction();

                float lX = aME.getX();
                float lY = aME.getY();

                switch (lAction) {
                    case MotionEvent.ACTION_DOWN:
                        ex = lX;
                        ey = lY + lTitleBarHeight;
                        break;
                    case MotionEvent.ACTION_MOVE:
                        sx = ex;
                        sy = ey;
                        ex = lX;
                        ey = lY + lTitleBarHeight;
                        lCanvas.drawLine(sx, sy, ex, ey, p);
                        break;
                    case MotionEvent.ACTION_UP:
                    case MotionEvent.ACTION_CANCEL:
                        break;
                }
                lImgView.invalidate();
                return true;
            }
        });

    }
View Full Code Here

TOP

Related Classes of android.widget.ImageView

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.