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");
这是我的代码,如何为 API > 23 使用 setTextAppearance
感谢帮助
最佳答案
使用支持库中的 TextViewCompat
:
TextViewCompat.setTextAppearance(tv, android.R.style.TextAppearance_Medium);
关于android - setTextAppearance deprecated android怎么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38200019/