1 year ago
#48458
testivanivan
Android. Style for DialogFragment not working
I have project with two modules: app and design_utils. Inside my app module I use DialogFragment. I need to set style for my DialogFragment views from design_utils module. In turn, the design_utils module contains the file themes with all the styles I need.
When I directly try to set the styles for the views (in xml), it's not working. Only works if I additionally set the style (with primary, secondary colors and etc) from the design_utils module for my activity in the manifest: <activity
android:name=".TestActivity"
android:resizeableActivity="false"
android:screenOrientation="portrait"
android:theme="@style/Theme.DesignUtils"
android:windowSoftInputMode="adjustResize" />
However, I don't need to set this theme for the activity, I would like to set for my DialogFragment only. And so here my code:
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialogThemeContext = ContextThemeWrapper(context, R.style.Theme.DesignUtils)
return Dialog(
dialogThemeContext,
R.style.CustomAlertDialogStyle_Test
).apply {
setContentView(R.layout.dialog_test)
}
}
However, this doesn't work. The styles that I apply from the design_utils module to my views inside the dialog do not work. Please tell me what could be the problem.
android
android-theme
android-dialogfragment
android-styles
android-module
0 Answers
Your Answer