textAppearance を動的にセットする場合

TextView android:textAppearance を動的にセットする場合、
次のような実行、

 TextView textview = new TextView(getContext());
 textview.setTextAppearance(getContext(), android.R.attr.textAppearanceLarge);

android.R.attr.textAppearanceLarge を指定しても期待どおりにならない。

期待どおりにするには、、、

 textview.setTextAppearance(getContext(), android.R.style.TextAppearance_Large);

あるいは、setTextAppearance を呼ばずに、

 TextView textview = new TextView(getContext(), null, android.R.attr.textAppearanceLarge);

のようにする。

ついでのメモ。。。

LayoutParams で、マージンを指定するつもりで
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(10, 20, 10, 20);
textview.setLayoutParams(params);

と書いても、Dialog上で適用されない場合があり、の場合は、Padding を指定する。

textview.setPadding(10, 20, 10, 20);

setPadding を書いた場合、上の MATCH_PARENT 指定の LayoutParams をセットしなくても、
setLayoutParams を実行しなくても良いようだ。