码迷,mamicode.com
首页 > 移动开发 > 详细

android自定义View (五)view.requestLayout() 与 invalidate()

时间:2014-06-15 21:41:36      阅读:320      评论:0      收藏:0      [点我收藏+]

标签:android   style   class   blog   code   http   

一。要点

  1. If in the course of processing the event, the view‘s bounds may need to be changed, the view will call requestLayout().

  2. Similarly, if in the course of processing the event the view‘s appearance may need to be changed, the view will call invalidate().

  3. If either requestLayout() or invalidate() were called, the framework will take care of measuring, laying out, and drawing the tree as appropriate.

 

二。实例

 

    public void setSwitchTypeface(Typeface tf) {
        if (mTextPaint.getTypeface() != tf) {
            mTextPaint.setTypeface(tf);

            requestLayout();
            invalidate();
        }
    }


    public void setSwitchPadding(int pixels) {
        mSwitchPadding = pixels;
        requestLayout();
    }

 

 

 

android自定义View (五)view.requestLayout() 与 invalidate(),布布扣,bubuko.com

android自定义View (五)view.requestLayout() 与 invalidate()

标签:android   style   class   blog   code   http   

原文地址:http://www.cnblogs.com/yuyutianxia/p/3785540.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!