我想将Graphical Layout
节目的样式应用为Theme.DeviceDefault.Dialog.Alert
。我知道现在这是一种私人风格,我不能把它作为父母。
如何将这种风格发送到我的DialogFragment
?
(我的目标是API 15,也许我想使用minSdk API 12。)
这报告了一个错误(父母,就像我读过,现在是私人的):
<style name="MyDialogStyle" parent="@android:style/Theme.DeviceDefault.Dialog.Alert">
找不到与给定名称匹配的资源。
我刚看过我必须“复制”款式,但我找不到它的位置?
是的,有人可以帮帮我吗?我需要将该样式“克隆”为我的自定义样式。提前致谢。
DialogFragment的硬编码背景
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// TODO Auto-generated method stub
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(0));
return super.onCreateView(inflater, container, savedInstanceState);
}
我的自定义风格
<style name="MyDialogStyle">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:background">@android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
我访问过这些链接:
http://developer.android.com/reference/android/app/AlertDialog.html http://developer.android.com/guide/topics/ui/themes.html
http://daniel-codes.blogspot.com/2011/08/new-to-android-more-style-restrictions.html
答案 0 :(得分:1)
最后,我使用Dialog
而不是DialogFragment
解决了这个问题,因为最后一个不支持透明度布局。设置透明背景很容易设置新activity
并在Manifest
中设置样式。否则,我不得不使用活动而不是片段来更改对话框的结构。
我希望这能为他们节省数小时的研究时间。
再见!