layout=(RelativeLayout)findViewById(R.id.relate);
TextView tv = new TextView(DetailActivity.this);
layout.addView(tv);
tv.setTextAppearance(DetailActivity.this, android.R.style.TextAppearance_Medium);
tv.setGravity(Gravity.CENTER_HORIZONTAL);
tv.setText("Hello Man");
Here is my code how to use setTextAppearance for API > 23
Help Appreciated