简体   繁体   English

如何在Android上获得模糊效果?

[英]How do I get the blur effect on Android?

I have to provide a background blur effect like in the picture. 我必须提供图片中的背景模糊效果。 在此处输入图片说明

The first layer contains text and switch.There is another layer below it.The properties of this layer color: #f8f8f8 alpha: 82.The actual color is present in the lower layer.True color in the picture is #D42E2E.These layers may look better in the picture below. 第一层包含文本和切换,其下一层是第二层,该层颜色的属性为:#f8f8f8 alpha:82,实际颜色位于下层,图片中的真实颜色为#D42E2E。在下面的图片中看起来更好。 在此处输入图片说明

How can I accomplish this without using an external library? 如何在不使用外部库的情况下完成此任务?

This just looks like a gradient as background with light red center color and white border colors. 这看起来像是渐变色的背景,具有淡红色的中心色和白色的边框色。

You can use this Gradient Generator to create your gradient. 您可以使用此渐变生成器来创建渐变。 Save the gradient-code for example in your drawables-folder as gradient.xml and use this as background of your view. 例如,在您的drawables-folder中将gradient.xml代码另存为gradient.xml并将其用作视图的背景。

This could be your gradient 这可能是您的渐变

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<gradient
android:type="linear"
android:centerX="50%"
android:startColor="#FFFFFFFF"
android:centerColor="#FFFF8A8A"
android:endColor="#FFFFFFFF"
android:angle="90"/>
</shape>

Result : 结果

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM