If you set android:windowTranslucentNavigation to true in your theme in Lollipop the navigation bar won't be fully translucent like in KitKat. Instead it's a dark semi-transparant background. Does anyone here know what the alpha value is of that background?
I've made some test with navigation bar and found that alpha of navBar when android:windowTranslucentNavigation = true is 40% of black color.
So color in hex would be: #66000000
Here is steps how I calculated this value:
I made screenshot as presented below
Then I open it in Gimp image editor and take RGB values of each color
White is (255,255,255), white under navBar (153,153,153)
Grey is (150,150,150), grey under navBar (90,90,90)
Then I calculate as next:
255 is 100%
153 is x
x = 153 * 100 / 255 = 60%
So I calculated invert value of alpha channel, the true value of alpha channel is 100 - 60 = 40%
ARGB value of 40% is (102,0,0,0) in hex it's #66000000
Related
I'm reading this article about material design. In the list of colors, there is a number next to each color that seems to darken the color as its value goes up.
What does this number means, more precisely?
Edit: As all the answers are about the hex values, I'm adding this edit to clarify the question. My question is about the left hand side numbers like 700, 500, ... not the hex numbers (#3f51b5, ...)
Edit 2: In RGB model, each of the Red, Green or Blue can have a value in scale of 0 - 255. 0 means lack of the color and 255 means the color exists in full power. Is there a numerical meaning for the left hand side numbers? Can I calculate the '700' of a color, assuming '500' of it is #3F51B5? Or these numbers are just name for different shades of color in a palette?
Those values are the relative lightness/darkness or "tint" of the color, where 50 is lightest and 900 is darkest. The Material Design guidelines suggest using the 500 tint as your primary color and the 700 tint as the darker status bar color.
The Annn values are if you're using the color as your accent color.
See https://www.google.com/design/spec/style/color.html#color-ui-color-application
The other answers are correct as well, but I think you are asking about the left hand side numbers. You can use these to specify your theme colors in Angular-Material.
$mdThemingProvider.theme('default')
.primaryPalette('purple', {
'default': '700', // by default use shade from the palette for primary intentions
'hue-1': 'A400', // use shade for the <code>md-hue-1</code> class
'hue-2': '600', // use shade for the <code>md-hue-2</code> class
'hue-3': 'A100' // use shade for the <code>md-hue-3</code> class
})
// If you specify less than all of the keys, it will inherit from the default shades
.accentPalette('deep-purple', {
'default': '200' // use shade 200 for default, and keep all other shades the same
})
The numbers you see in use, correspond the left hand side numbers to set up colors. My site is using variations of the purple theme in this example, and I can set the hue's different from what the Google settings were.
The numbers refer to the darkness of a shade variant (inverse of HSL lightness). The numbers use a scale of 0 to 1000, where 0 is white and 1000 is black.
From the Android documentation for R.color:
system_accent1_0
Lightest shade of the accent color used by the system. White.
system_accent1_10
Shade of the accent system color at 99% lightness.
system_accent1_100
Shade of the accent system color at 90% lightness.
And so on.
The general formula is shadeVariant = 1000 - (lightness * 1000).
(The one curious exception is that the 500 shade variant uses 49% lightness instead of 50%, but this is probably an implementation detail that could be ignored when re-implementing.)
Knowing the formula should additionally make it easy to calculate these values directly. For example, using Polished, you would be able to setLightness(accent, 0.9) to calculate the 100 shade variant of an accent colour yourself in a Node.js app. From there it would be easy to build a utility function that can generate any variant of any colour.
I found some information in this angular.io guide to theming:
In Material Design, each hues in a palette has an identifier number. These identifier numbers include 50, and then each 100 value between 100 and 900. The numbers order hues within a palette from lightest to darkest.
There you have it, the answer to your question: Those numbers are just static identifiers.
As an example of how they can be used, this guide to "Reading hues from palettes" states:
You can use the get-color-from-palette function to get specific hues from a palette by their number identifier.
#use '~#angular/material' as mat;
$my-palette: mat.define-palette(mat.$indigo-palette);
.my-custom-style {
background: mat.get-color-from-palette($my-palette, '500');
color: mat.get-color-from-palette($my-palette, '500-contrast');
}
The number which you are seeing is the HEX (hexadecimal) values for the color tone and the color. You can use it in CSS files instead of writing i.e. black, white or blue.
From WIKI:
"A hex triplet is a six-digit, three-byte hexadecimal number used in HTML, CSS, SVG, and other computing applications to represent colors. The bytes represent the red, green and blue components of the color. One byte represents a number in the range 00 to FF (in hexadecimal notation), or 0 to 255 in decimal notation"
More about it here https://en.wikipedia.org/wiki/Web_colors
The number is codes given to each and all colorssupported by the system. Eachh color code contains symbol "#" and 6 letters or numbers. These numbers are in hexadecimal numeral system. For example "FF" in hexadecimal represents number 255 in Decimal.
Meaning of symbols:
The first two symbols in HTML color code represents the intensity of red color. 00 is the least and FF is the most intense. The third and fourth represents intensity of green and fifth and sixth represents the intensity of blue. So with combining the intensity of red, green and blue we can mix almost any color that our heart desire.
Examples:
#FF0000: With this HTML code we tell browser to show maximum of red and no green and no blue. The result is of course pure red color.
#00FF00 - This results in pure green.
how to get parseColor color value to transparent.
mPaint.setColor(Color.parseColor("#FFFF00"));
thanks for help
Suppose your preferred color is red #FF0000
Adding 00 in the beginning will make it 100% transparent and adding FF will make it 100% solid.
So, 100% transparent color is: #00ff0000
and 100% solid color is: #ffff0000
And any value in between 00 to ff can be used to adjust the transparency.
just used android color string
mPaint.setColor(getResources().getColor(android.R.color.transparent));
You can use Color.TRANSPARENT if you do not want to change the transparency level.
import android.graphics.Color;
// use Color.TRANSPARENT
mPaint.setColor(Color.TRANSPARENT);
https://developer.android.com/reference/android/graphics/Color#TRANSPARENT
You can use Color.argb(int alpha, int red, int green, int blue)
Alpha corresponds to transparency. 0 for fully transparent. 255 for opaque.
http://developer.android.com/reference/android/graphics/Color.html#argb(int,%20int,%20int,%20int)
Return a color-int from alpha, red, green, blue components. These
component values should be [0..255], but there is no range check
performed, so if they are out of range, the returned color is
undefined.
I've been trying to use remoteView.setFloat(R.id.remote_background, "setAlpha", (float) 0.7); to set background transparency/alpha, but I'm getting "Error loading widget". I've read that you can set transparency by adding a hex value in front of a color. But since I'm getting the color from ColorPicker and it's an integer value (example: -13890612), I don't know how to use it.
You should use hex notation to see the color as it is in format RRGGBB, so your -13890612 should be rather peeked as 2C0BCC which makes more sense as you can easily say what are values of each components of the color. And to add alpha channel (which is value from 0 - (full transparent) to 0xff (full opaque)), just OR the right value with your color and use. I.e. to make it semi transparent OR 0x80:
int rgb = 0x2C0BCC;
int argb = 0x80000000 | rgb;
USe setInt(R.id.remote_background, "setBackgroundColor", colorInt); instead.
Id like to take a black background color and give it 10% opacity, what is the hexidecimal code for this in android?
0xAARRBBGG, AA is the alpha channel which determines transparency. 00 is fully transparent, FF is fully opaque. 10% would be about 0x19.
I'm trying to figure out one simple thing: how to set a background color in Android view. Here is the code in an Activity:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View v = new View(this);
setContentView(v);
v.setBackgroundColor(23423425);
}
and all I get is black screen.
The integer you set is easier represented as a hex value. The hex values are 0xAARRGGBB.
A - represents the Alpha value which is how transparent the color is. A value of FF means it's not transparent at all. A value of 00 means the color won't be shown at all and everything behind it will be visible.
R - Red value; self-explanatory
G - Green value; self-explanatory
B - Blue value; self-explanatory
What you entered in hex is 0x016569C1 which has an Alpha values of 1 (barely visible). Put, 0xFFFF0000 and you'll have a red background.
You are passing in the color incorrectly. DeeV got to it before me but you need to use a hex value.
Here is a link that lists all combinations for easy access.
Colors for Android
You can also set in the XML by using
android:background = "#FF00000000"
Which would be black.
Common way to represent color in ARGB(sometimes RGBA but it is just a naming) model is hexadecimal. No one uses decimal numeral system to represent color digitally.
let's set yellow color to button's text: button.setTextColor(0xFFFFFF00);. Now We set yellow to out button's text.
ARGB consists of 4 cannel. each with 8-bit. first channel is alfa - 0xFFFFFFFF; alfa is opacity level(in this case we have max value of it). second is red - 0xFFFFFF00, and so on; green and blue respectively.
The easiest way to create color in ARGB color model with decimal numeral system is to use Color class.
Color class has all basic static functions and fields.
In your case you can use static function Color.rgb(int red, int, green, int blue) where red, green, blue must be in the range of 0 to 255. Alfa bits by default is set to max - 255 or in hex - 0xff.
Now you know how to represent color in hexadecimal numeric system it will be very easy to create color in xml resource file.