我想让app看起来像超省电模式(galaxy s5)。它改变屏幕只显示黑白颜色。我不知道如何制作它。 任何人都可以提供一些建议或信息,如何做到这一点? 非常感谢。
答案 0 :(得分:8)
// Create a paint object with 0 saturation (black and white)
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
Paint greyscalePaint = new Paint();
greyscalePaint.setColorFilter(new ColorMatrixColorFilter(cm));
// Create a hardware layer with the greyscale paint
v.setLayerType(LAYER_TYPE_HARDWARE, greyscalePaint);
将这些代码用于根布局。
答案 1 :(得分:2)
如果您要将整个应用设计为黑/白或灰度,最简单的方法是在res / values / colors.xml中定义颜色调整,以便在设计和着色时仅包含黑/白/灰色你的应用。
如果你有一个完全着色的应用程序,并希望翻转设置上的所有内容或者想要灰度图像,我建议使用用户首选项布尔值并在onCreate中定义一个方法。
要将ImageViews变为黑白,您可以使用:
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(0);
ColorMatrixColorFilter colorFilter = new ColorMatrixColorFilter(colorMatrix);
imageView.setColorFilter(colorFilter);
对于所有视图,您应该能够对其应用色调以删除颜色: 使用android:backgroundTint,或更改按钮或复选框的颜色属性。
答案 2 :(得分:0)
你的基本想法是有缺陷的。
三星必须建立Android才能制作Ultra Power Saving Mode.
这不是你可以通过创建一个黑白应用程序来创建自己的东西。
What happens if the battery drains away? Some start turning things off, like Wi-Fi or Bluetooth, or even just activate Airplane Mode. Lower the screen's brightness. A bunch of random, individual things all meant to give the battery just a little bit longer of a push.
Samsung wanted to make that easier, and take things a bit further, by including their Ultra Power Saving Mode in the Galaxy S5. It does all of those things, with some tweaks. Instead of lowering the screen's brightness only, it actually turns it grayscale, and gives you a black-and-white representation of your phone's display. So even if you do use an app, like respond to an important text message, it'll remain grayscale. It turns off things like Bluetooth and Wi-Fi. It will also turn off your phone's data connection when the display is off, and switch back on when you start using your phone.
Even the lock screen changes, as you'll no longer see the weather report there, and Samsung's fancy animation is gone, replaced by a simple indicator as to how to unlock the device. Once you do, the next screen is just a short six-item list of pre-approved applications that you can use while in the mode.
所以有很多东西,当所有组合将节省设备的电池;将屏幕从彩色变为灰度不会是一个重大改进。此外,根据您的实施方式,您实际上可能会使性能变差!
三星几乎调整了所有内容并对所有内容进行了测试,以确保该模式下的所有调整实际上都能节省电池电量。这不会是你自己要做的事情。
答案 3 :(得分:-3)
转到您的设置。单击省电模式。打开灰度模式。