title: Paint instance never initializated in custom ViewGroup constructor
body: <p>I have a custom ViewGroup with the follow constructors:</p>
  
  <pre><code>public BoxGridLayout(Context context) {
      super(context, null);
  }
  
  public BoxGridLayout(Context context, AttributeSet attrs) {
      super(context, attrs, 0);
  }
  
  public BoxGridLayout(Context context, AttributeSet attrs, int defStyle) {
      super(context, attrs, defStyle);
  
      //Recupero gli attributi che ho creato nel file attrs.xml
      TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BoxGridLayout, 0, defStyle);
  
      int strokeWidth = a.getDimensionPixelSize(R.styleable.BoxGridLayout_separatorWidth, 0);
      int strokeColor = a.getColor(R.styleable.BoxGridLayout_separatorColor, Color.WHITE);
  
      a.recycle();
  
      mGridPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mGridPaint.setStyle(Paint.Style.STROKE);
      mGridPaint.setColor(strokeColor);
      mGridPaint.setStrokeWidth(strokeWidth);
  }
  </code></pre>
  
  <p>After that in the dispatchDraw() method, I need mGridPaint to create a grid:</p>
  
  <pre><code>@Override
  protected void dispatchDraw(Canvas canvas) {
      super.dispatchDraw(canvas);
  
      for (int i = 0; i &lt;= getWidth(); i += (getWidth() / COUNT)) {
          canvas.drawLine(i, 0, i, getHeight(), mGridPaint);
      }
      for (int i = 0; i &lt;= getHeight(); i += (getHeight() / COUNT)) {
          canvas.drawLine(0, i, getWidth(), i, mGridPaint);
      }
  }
  </code></pre>
  
  <p>I used this ViewGroup in a layout file like the following:</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
  
  &lt;com.example.customview.widget.BoxGridLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_gravity="center"
      app:separatorWidth="2dp"&gt;
  
     ....
     ....
  
  
  &lt;/com.example.customview.widget.BoxGridLayout&gt;
  
  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p><strong>Problem:</strong> Sadly I have a NullPointerException on mGridPaint:</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to read from field 'long android.graphics.Paint.mNativePaint' on a null object reference
          at android.view.GLES20Canvas.drawLines(GLES20Canvas.java:862)
          at android.view.GLES20Canvas.drawLine(GLES20Canvas.java:852)
          at it.liqid.customview.widgets.BoxGridLayout.dispatchDraw(BoxGridLayout.java:94)
          .....
  </code></pre>
  
  <p>How can I fix this error?
  Thanks!</p>