How to set a theme for DialogFragment

Can someone explain why this expression works fine:

setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo); 

and the next statement does not deliver

 setStyle(DialogFragment.STYLE_NO_TITLE, R.style.dialog); 

This is what I have in the style department:

 <style name="dialog"> <!-- title encapsulating main part (backgroud) of custom alertdialog --> <item name="android:windowFrame">@null</item> <!-- turn off any drawable used to draw a frame on the window --> <item name="android:windowBackground">@null</item> <!-- turn off any drawable used to draw a frame on the window --> <item name="android:windowIsFloating">true</item> <!-- float the window so it does not fill the screen --> <item name="android:windowNoTitle">true</item> <!-- remove the title bar we make our own--> <item name="android:windowContentOverlay">@null</item> <!-- remove the shadow from under the title bar --> </style> 
+6
source share
2 answers

It may be too late to reply, but try using the code in the onCreate snippet as

 @Override public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setStyle(DialogFragment.STYLE_NO_TITLE, R.style.dialog); } 
+20
source

Try to set the parent theme, for example

 <style name="dialog" parent="@android:style/Theme.Dialog"> 
0
source

Source: https://habr.com/ru/post/947322/


All Articles