• 视图类,双缓冲,图片资源的显示


    public class TestView extends View implements Runnable {

        Bitmap m_bitQQ;

        Bitmap m_bitCanvas;

        Canvas m_canvas;

    Paint m_paint;

     

        public TestView(Context context) {

            super(context);

            m_bitQQ = ((BitmapDrawable)getResources().

    getDrawable(R.mipmap.img1)).getBitmap();

            DisplayMetrics dm = new DisplayMetrics();

            WindowManager wm =(WindowManager)context.

    getSystemService(Context.WINDOW_SERVICE);

            wm.getDefaultDisplay().getMetrics(dm);

            m_bitCanvas = Bitmap.createBitmap(dm.widthPixels, dm.heightPixels, Bitmap.Config.ARGB_8888);

            m_canvas = new Canvas();

            m_canvas.setBitmap(m_bitCanvas);

            m_paint = new Paint();

            m_canvas.drawBitmap(m_bitQQ, 0, 0, m_paint);

            new Thread(this).start();

    }

     

        protected void onDraw(Canvas canvas) {

            super.onDraw(canvas);

            canvas.drawBitmap(m_bitCanvas, 0, 0, m_paint);

    }

     

        public void run() {

            while (!Thread.currentThread().isInterrupted())

            {

                try {

                    Thread.sleep(100);

                }

                catch (InterruptedException e)

                {

                    Thread.currentThread().interrupt();

                }

                postInvalidate();

            }

        }

    }

  • 相关阅读:
    如何在winform的numericUpDown中显示小数点
    Jquery attr 和removeAttr 的简单使用
    Linux下的多进程编程初步(转载)
    扩展GCD和线性模方程组
    05、Flutter常用组件
    12、Flutter组件装饰
    10、Flutter资源和图片
    09、Flutter手势控制
    04、FlutterDart语法
    07、FluterCupertino
  • 原文地址:https://www.cnblogs.com/CipherLab/p/14434134.html
Copyright © 2020-2023  润新知