zoukankan      html  css  js  c++  java
  • Android -- setWillNotDraw()

    干货                                                                                   

    处理onDraw()方法不被执行的解决方法:

    setWillNotDraw(false);

    官方文档的解释:

    If this view doesn't do any drawing on its own, set this flag to allow further optimizations. By default, this flag is not set on View, but could be set on some View subclasses such as ViewGroup. Typically, if you override onDraw(Canvas) you should clear this flag.

    用法                                                                                   

    public class LayoutLayout extends LinearLayout {  
      
            public LayoutLayout (Context context, intposition) {  
                    super(context);  
                    setWillNotDraw(false);  
            }  
      
            @Override  
            protected void onDraw(Canvas canvas) {   
                    super.onDraw(canvas);  
                    }  
            }  
    }

    总结                                                                                   

    设置view是否更改,如果用自定义的view,重写ondraw()应该将调用此方法设置为false,这样程序会调用自定义的布局。

    我是天王盖地虎的分割线                                                             

  • 相关阅读:
    支付宝及时到帐接口使用详解
    Linux 天翼3G上网
    VBS常用函数及功能
    mencoder和ffmpeg参数详解
    C# 将数据导出到Excel汇总
    C# WinForm开发系列 Excel
    C#中的String.Format方法
    Google Maps API 代码
    ffmpeg的使用
    C# WinForm开发系列 Crystal Report
  • 原文地址:https://www.cnblogs.com/yydcdut/p/4190008.html
Copyright © 2011-2022 走看看