※ここで言う動的とはjavaプログラム中でstyleを適用することを指します。
=== 目次 ===
静的にstyleを適用する方法
静的にstyleを適用するには、XMLファイル中のViewのstyle属性にsytleリソース名を指示します。<LinearLayout
style="MyStyle"
>
...
</LinearLaytout>
動的にstyleを適用する方法
動的にstyleを適用するには、Viewのコンストラクタの引数にContextThemeWrapperのオブジェクトを挿入します。
LinearLayout LL = new LinearLayout(new ContextThemeWrapper(context, R.style.MyStyle));
ContextThemeWrapperの第1引数はContext, 第2引数はstyleリソース名です。