如何使所有应用程序的屏幕仅在android中显示白色和黑色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24900803/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to make screen only display white and black color in android for all app
提问by luyentm
I want to make app look like Ultra Power Saving Mode (galaxy s5). it change screen only display black and white color. I don't know how to make it. Can anyone give some advice or information about how to do this? Thanks a lot.
我想让应用程序看起来像超省电模式(galaxy s5)。它改变屏幕只显示黑白颜色。我不知道怎么做。任何人都可以就如何做到这一点提供一些建议或信息吗?非常感谢。
回答by DaSqy Stc
// 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);
use these code to the root layout.
将这些代码用于根布局。
回答by afathman
If you are designing your entire app to look black/white or grayscale, the easiest thing to do is to define your color palate in res/values/colors.xml to include only black/white/gray colors when designing and coloring your app.
如果您要将整个应用程序设计为黑色/白色或灰度,最简单的做法是在 res/values/colors.xml 中定义您的色觉,以便在设计和着色应用程序时仅包含黑色/白色/灰色。
If you have a fully colorized app and wish to flip everything on a setting or have images that you wish to grayscale, I would recommend using a user preference boolean and define a method in your onCreate.
如果您有一个完全彩色的应用程序并希望翻转设置中的所有内容或希望对图像进行灰度处理,我建议您使用用户首选项布尔值并在您的 onCreate 中定义一个方法。
To turn your ImageViews into black and white, you can use:
要将您的 ImageViews 变成黑白,您可以使用:
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(0);
ColorMatrixColorFilter colorFilter = new ColorMatrixColorFilter(colorMatrix);
imageView.setColorFilter(colorFilter);
For all Views, you should be able to apply a Tint to it to remove the colors: using the android:backgroundTint, or to change the color properties of buttons or checkboxes.
对于所有视图,您应该能够对其应用 Tint 以移除颜色:使用 android:backgroundTint,或者更改按钮或复选框的颜色属性。
回答by Christopher Rucinski
Your basic idea is flawed.
你的基本想法是有缺陷的。
Samsung had to build off of Android to make the Ultra Power Saving Mode.
This isn't something that you can just create yourself simply by creating a black and white app.
三星必须在 Android 的基础上构建才能使Ultra Power Saving Mode.
这不是您可以通过创建黑白应用程序来创建自己的东西。
Here is a desription of 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.
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.
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.
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.
So there are MANY things that when all combined will save the battery of the device; changing the screen from color to gray-scale will not be a major improvement. Also, depending on how you implement it, you can actually be making the performance worse!!
所以有很多东西,当所有的东西结合起来可以节省设备的电池;将屏幕从彩色改为灰度不会有重大改进。此外,根据您的实施方式,您实际上可能会使性能变得更糟!!
Samsung has tweaked almost everything and tested everything to make sure that all the tweaks in that mode actually save battery power. That isn't going to be something that you will be doing by yourself.
三星几乎对所有内容进行了调整并测试了所有内容,以确保该模式下的所有调整实际上都可以节省电池电量。这不会是你自己会做的事情。
回答by Sandy
Go to your settings. Click on power saving mode. Turn on gray scale mode.
转到您的设置。点击省电模式。打开灰度模式。