Android dialog custom style

我怕爱的太早我们不能终老 提交于 2019-12-11 01:35:51

问题


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?


回答1:


On initializing :

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


来源:https://stackoverflow.com/questions/11332928/android-dialog-custom-style

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!