Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我看到的许多新的 Android 应用程序都在其背景上使用了噪点效果,通常是渐变。有趣的是,一些应用程序在整个应用程序中使用径向渐变来产生这种效果,这将需要大量的磁盘空间来存储图像。现在 Android 有 GradientDrawable 可以很容易地创建渐变。我正在考虑以编程方式创建噪声效果。
以前有没有其他人这样做过,如果有,你是怎么做的?您只是使用图像还是编写自己的自定义噪声叠加层?
如果您只想以编程方式消除色带,您可以通过覆盖onAttachedToWindow()活动的回调来实现,如下所示:
onAttachedToWindow()
@Override public void onAttachedToWindow() { super.onAttachedToWindow(); Window window = getWindow(); // Eliminates color banding window.setFormat(PixelFormat.RGBA_8888); }
这对我的正常应用程序非常有效。我还没有用小部件测试这个。