Android对话框自定义样式 [英] Android dialog custom style

查看:96
本文介绍了Android对话框自定义样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个适用于该活动的自定义主题:

I have a custom theme which is applied to the activity:

<style name="Sample" parent="android:Theme">
  <item name="android:dialogTheme">@style/Sample.Dialog</item>
</style>

<style name="Sample.Dialog" parent="android:Theme.Dialog">
  <item name="android:windowBackground">@drawable/sample_background</item>
</style>

我正在创建一个示例对话框,如下所示:

I'm creating a sample Dialog like this:

Dialog dialog = new Dialog(SampleActivity.this);
dialog.setContentView(R.layout.sample_layout);
dialog.show();

我的自定义对话框样式未应用.创建的对话框仍然具有标准背景.怎么了?

My custom dialog style isn't applied. Created dialog still has the standard background. What's wrong here?

推荐答案

初始化时:

Dialog dialog = new Dialog(SampleActivity.this, R.style.Sample.Dialog);

这篇关于Android对话框自定义样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆