【Android】Layout PreviewのDefault Themeを設定する
AndroidManifest.xmlでapplicationにthemeを設定しているとレイアウトプレビューのThemeにそれが反映される。
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.NavigationComponentSample">
そのため、モジュール分割等でAndroidManifest.xmlが分割されている場合などは、そちらにもthemeの設定をしないとそのモジュール内のレイアウトプレビューにthemeが適用されません。
<application android:theme="@style/Theme.NavigationComponentSample"> <activity android:name=".HogeActivity" /> </application>
スタイルを変更してもプレビューに反映されずビルドしないと確認できなくて困っていたらこれが原因だった。
こちらを参考にしました。