如何设置DialogFragment的主题 [英] How to set the theme for DialogFragment
本文介绍了如何设置DialogFragment的主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以解释一下为什么这种说法效果很好吗?
Can someone please explain why this statement works perfectly well:
setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo);
而下一条语句不传递
setStyle(DialogFragment.STYLE_NO_TITLE, R.style.dialog);
这是我在样式部门中拥有的东西:
This is what I have in the style's 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>
推荐答案
尝试将片段的onCreate中的代码用作
Try using the code in onCreate of the fragment as
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NO_TITLE, R.style.dialog);
}
这篇关于如何设置DialogFragment的主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文