Q:

Custom view not getting drawn in GridLayout

I've got a custom view that I'm trying to fill a GridLayout with. The custom view consists of a TextView inside of a circle. The problem I'm having is that the onDraw() method of my custom view never gets called so I always end up with a blank screen. When I populate my GridLayout with just regular TextViews it works just fine so I'm guessing the problem lies somewhere with my custom View.
My onCreate:
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample_collection);

    gl = (GridLayout) findViewById(R.id.grid_sample_collection);
    gl.setColumnCount(9);
    gl.setRowCount(9);
    LayoutInflater inflater = LayoutInflater.from(this);
    for(int i=0;i<gl.getRowCount();i++){
        for(int j=0;j<gl.getColumnCount();j++){
            SampleCollectionView sampleCollectionView = new SampleCollectionView(this);
            sampleCollectionView.setLabelText(i + "." + j);
            gl.addView(sampleCollectionView);

            //Adding the TextViews shown below works just fine
            //TextView t = new TextView(this);
            //t.setText(i + "." + j);
            //t.setTextSize(30f);
            //t.setPadding(30, 30, 30, 30);
            //gl.addView(t);
        }
    }
    int childCount = gl.getChildCount();
    for (int i= 0; i < childCount; i++){
        final SampleCollectionView sampleCollectionView = (SampleCollectionView) gl.getChildAt(i);
        //final TextView text = (TextView) gl.getChildAt(i);
        sampleCollectionView.setOnClickListener(new View.OnClickListener(){
            public void onClick(View view){
                Log.d("OnClickListener: ", "Clicked text: " + sampleCollectionView.getLabelText());
            }
        });
    } 
}

My custom view:
public SampleCollectionView(Context context){
    super(context);
    init();
}

public SampleCollectionView(Context context, AttributeSet attrs) {
    super(context, attrs);

    //get the attributes specified in attrs.xml using the name we included
    TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
            R.styleable.SampleCollectionView, 0, 0);

    try {
        //get the text and colors specified using the names in attrs.xml
        circleText = a.getString(R.styleable.SampleCollectionView_circleLabel); //0 is default
        circleCol = a.getInteger(R.styleable.SampleCollectionView_circleColor, 0);
        circleBorderCol = a.getInteger(R.styleable.SampleCollectionView_circleBorderColor, 0);
        labelCol = a.getInteger(R.styleable.SampleCollectionView_labelColor, 0);
    } finally {
        a.recycle();
        init();
    }
}

public void init(){
    mPaint = new Paint();
}

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    int viewWidthHalf = this.getMeasuredWidth()/2;
    int viewHeightHalf = this.getMeasuredHeight()/2;

    int radius = 0;

    if(viewWidthHalf>viewHeightHalf)
        radius=viewHeightHalf-10;
    else
        radius=viewWidthHalf-10;

    mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaint.setAntiAlias(true);
    mPaint.setColor(circleCol);
    canvas.drawCircle(viewWidthHalf, viewHeightHalf, radius, mPaint);

    mPaint.setTextAlign(Paint.Align.CENTER);
    mPaint.setTextSize(20);

    canvas.drawText(circleText, viewWidthHalf, viewHeightHalf, mPaint);
}

EDIT: After some testing I found out that the height and weight of my custom views were 0. After using setMinimumHeight and setMinimumWidth they are actually getting drawn and are responding to clicks. The only problem now is that for some reason, all of the custom views are completely invisible...
EDIT 2: Turns out the views weren't visible because I wasn't setting the View's properties like circleCol properly, which caused them to be set to their default value (0).

A:

I managed to figure out what was going wrong. I created my custom Views without specifying a height/width. Naturally, this led to them getting a height and width of 0, with the GridLayout getting the same constraints as it was set to wrap_content. 
After giving my views a proper height and width with the setMinimumHeight and setMinimumWidth methods I ran into another issue: The views weren't visible. They were being drawn as the onClickListener was responding to taps on various parts of the screen but I couldn't see them. The cause of this was the same thing that was responsible for the height and width being 0: The custom View's color properties weren't set properly. I was attempting to do this via XML but for some reason it couldn't retrieve the values of the properties I had specified in my XML file. Because the properties weren't specified, they reverted to their default values which resulted in no color being specified and no string getting supplied to the label. I fixed this by programmatically setting the properties.

