Android Activity背景影响alertDialog
我有一个这样创建的样式:
<style name="myStyle" parent="@android:style/Theme.Dialog">
<item name="android:textColor">#FFFFFF</item>
<item name="android:background">#000099</item>
</style>
然后我创建了一个 xml 和一个活动,并在清单中声明了此
<activity android:name=".Try"
android:theme="@style/myStyle" >
</activity>
然后当我启动此活动时,我有一个带有背景颜色(蓝色)的 xml; 问题是,当我创建一个警报对话框时,
AlertDialog.Builder dialog = new AlertDialog.Builder....
它也受到这个背景的影响(它看起来更像是它后面的一个蓝色矩形,比对话框大,并且从所有 4 个侧面出来)。 我不希望这样,我想为警报对话框使用另一种样式。
我怎样才能禁用这个功能?
I have a style I created like this:
<style name="myStyle" parent="@android:style/Theme.Dialog">
<item name="android:textColor">#FFFFFF</item>
<item name="android:background">#000099</item>
</style>
Then I created an xml and an activity, and in the manifest declared this
<activity android:name=".Try"
android:theme="@style/myStyle" >
</activity>
Then when I start this activity I have an xml with a background color (blue);
THe problem is , when I create an Alert Dialog
AlertDialog.Builder dialog = new AlertDialog.Builder....
It is also affected by this background (It looks more like a blue rectangle behind it that is bigger then the dialog and is coming out from all 4 sides).
I dont want it to be, I want to use another style for the alert dialog.
How can I disable this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是说弹出对话框时您的活动背景太突出了吗?如果是这样,您可以使用以下代码模糊背景中的内容:
或者您是说您的活动的背景正在应用于对话框的背景...?
Are you saying that the background of your activity is too prominent when the dialog pops up? If so, you can blur what's in the background with the following code:
Or are you saying that the background of your activity is being applied to the background of your dialog...?
我设法解决了这个问题,不是全部解决,而是绕过它。
而不是使用:
#000099
我用过
IMAGE_NAME
我在“drawable”文件夹中添加了一个绿色矩形图像。
这使得背景变成图像而不是绘制它,并且图像不会影响Dailog。
它看起来会有点不同(例如它也会覆盖白色边框),但比以前更好。
I managed to fix that, well not entirley but to pass around it.
Instead of using:
#000099
I used
IMAGE_NAME
and I added a green rectangle image at the "drawable" folder.
This makes the background to become from an image instead of painting it, and the image does not affect the Dailog.
It will look a bit different (for example it will cover the white border as well) but it is better then before.