Try the following. I have not tested it. Let me know if you have any problems.
Define the styles like this
<style name="MyStyleText">
<item name="android:textColor">#ff0000</item>
<item name="android:textSize">12sp</item>
<item name="android:shadowColor">#ffffff</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">0</item>
<item name="android:shadowRadius">10</item>
</style>
And in java file
RelativeLayout.LayoutParams lp ;
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
RelativeLayout.LayoutParams textLP ;
textLP = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
RelativeLayout rl = new RelativeLayout(this);
TextView tv = new TextView(this);
tv.setText(getString(R.string.hello_world));
tv.setTextAppearance(getApplicationContext(), R.style.MyStyleText);
rl.addView(tv, textLP);
this.addContentView(rl, lp);