Android背景噪音效果

发布于 2024-09-15 06:44:24 字数 341 浏览 1 评论 0原文

我见过的很多新的 Android 应用程序都使用噪声效果< /a> 在他们的背景上,通常是渐变的。有趣的是,一些应用程序在整个应用程序中使用半径渐变来实现这种效果,这将需要大量的磁盘空间来存储图像。现在Android有了GradientDrawable,可以非常轻松地创建渐变。我正在考虑以编程方式创建噪音效果。

以前有其他人这样做过吗?如果是的话,你是怎么做的?您只是使用图像还是编写自己的自定义噪声叠加层?

A lot of new Android applications I've been seeing are using a noise effect on their backgrounds, usually a gradient. What interesting is that some applications use radiel gradients throughout their application with this effect, which would require a lot of disk space for the images. Now Android has GradientDrawable which can create gradients very easily. I was thinking about creating the noise effect programmatically.

Has anyone else done this before and if so, how did you go about it? Did you just use an image or write your own custom noise overlay?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吐个泡泡 2024-09-22 06:44:24

如果您只想以编程方式消除色带,您可以通过覆盖 Activity 的 onAttachedToWindow() 回调来实现,如下所示:

@Override
public void onAttachedToWindow() {
  super.onAttachedToWindow();
  Window window = getWindow();
  // Eliminates color banding
  window.setFormat(PixelFormat.RGBA_8888);
}

这对于我的正常应用程序非常有效。我还没有用小部件对此进行测试。

If you just want to eleminate the Color Banding programmaticaly you can do so by overiding the onAttachedToWindow() callback of your activity like this:

@Override
public void onAttachedToWindow() {
  super.onAttachedToWindow();
  Window window = getWindow();
  // Eliminates color banding
  window.setFormat(PixelFormat.RGBA_8888);
}

This worked very well for my normal applications. I didn't test this with widdgets yet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文