TextView tex = new TextView(MemeActivity.this);
tex.setTextColor(Color.WHITE);
tex.setGravity(Gravity.CENTER);
tex.setTextSize(TypedValue.COMPLEX_UNIT_PX, topLayoutEdtTxt.getTextSize() * Math.min(ratioX, ratioY));
tex.setTypeface(Const.memFontTypeFace(MemeActivity.this));
tex.setFadingEdgeLength((int)(5 * Math.min(ratioX, ratioY)));
tex.setInputType(InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS|InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
tex.setBackgroundColor(Color.MAGENTA);
tex.setSingleLine(true);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams((int)(topLayoutEdtTxt.getWidth()*ratioX),(int)(topLayoutEdtTxt.getHeight()*ratioY));
params.gravity = Gravity.CENTER;
tex.setText("Some Text");
tex.setLayoutParams(params);Add a code snippet to your website: www.paste.org