一。要点

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

 

 

 

相关文章:

  • 2021-12-30
  • 2021-05-08
  • 2021-10-09
猜你喜欢
  • 2021-08-10
  • 2022-01-15
  • 2021-09-29
  • 2021-05-19
  • 2021-09-15
相关资源
相似解决方案