RelativeLayout's gravity:center won't work
<p>I'm trying to make a function, which would return a RelativeLayout, with an ImageView and a TextView in the center.</p>

<pre><code>public RelativeLayout makeKey(String letter, int alfa)
{

    final RelativeLayout RelBtn = new RelativeLayout(this);
    RelBtn.setGravity(Gravity.CENTER);
    RelBtn.setLayoutParams(new LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT ));

    final ImageView ivBg = new ImageView(this);
    ivBg.setImageBitmap(bmBtnBg);
    ivBg.setPadding(5, 5, 5, 5);
    RelBtn.addView(ivBg);

    TextView tvLetterSHD = new TextView(this);
    tvLetterSHD.setTextSize(22);
    tvLetterSHD.setTypeface(null, Typeface.BOLD);
    tvLetterSHD.setTextColor(0xFF000000);
    tvLetterSHD.setText(letter);
    tvLetterSHD.setPadding(0, 3, 0, 0);
    RelBtn.addView(tvLetterSHD);

    TextView tvLetter = new TextView(this);
    tvLetter.setTextSize(22);
    tvLetter.setTypeface(null, Typeface.BOLD);
    tvLetter.setTextColor(0xFFFFFFFF);
    tvLetter.setText(letter);
    RelBtn.addView(tvLetter);

    return RelBtn;
}
</code></pre>

<p>Yet I'm getting something like this, as you can see, the TextView is off center.</p>

<p>Any ideas what might be wrong? Thanks! :)</p>

<p><img src="http://i.stack.imgur.com/IRFoy.png" alt="enter image description here"></p>
