What does the % symbol mean in Android's material design button style? - android

I'm trying to implement an Android button with a raised-button style.
Under Google's Material Design Section on flat and raised button states, it gives a visual and then some details used to implement the design:
Flat Light/Light theme
Minimum width: 88dp
Height: 36dp
Hover: 20% #999999
Pressed: 40% #999999
Disabled text: 26% #000000
For the hover and pressed state, what does the % symbol represent?
Which property does it refer to?

The percentage sign % represents the alpha value of the shade,Like 26% #000000 has an equivalent of rgba(0,0,0,2.6).

Related

Fill shape with text with two different color

I tried to achieve this but I am only able to achieve to fill object (shape).
My requirement is to change text color along with shape filling.
Shape can be filled with percentage like till
10% to 50% = Green
51% to 80% = Yellow
81% to 100% = Red
When Yellow color fills background of ":" in shape, it will change color to "White" which is previously "Yellow". Size of this shape is also dynamic.
What I tried and achieved?
I am able to fill shape with percentage but failed to change color when it reaches to edge of text.
I wrote a custom view. You get this double color effect using Path APIs. But for Android 1+ compatibility, you should use Region API and above Kitkat (19+) you can use just Path API.
Let's go through the concept of how to achieve this effect step by step:
There are three shapes we need to draw - Outline Rounded Stroke + Orange Progress Bar + the text itself
We draw the stroke as it is
But for the Progress bar, we need to remove the text that intersects with it and basically make the text intersection transparent. (DIFFERENCE)
Also for the Progress Bar, we have to show only the part of the rectangle that intersects with the outer rounded stroke path. (INTERSECTION)
And similarly, for the text, on the left side we basically chop off the parts that intersects with the progress bar. And we only show the right side of the text that is orange in color. (DIFFERENCE again)
If you are using API 19+, this is how the critical code snippet looks like:
croppedProgressPath.op(progressPath, textPath, Path.Op.DIFFERENCE);
croppedProgressPath.op(progressStrokePath, Path.Op.INTERSECT);
————————————
croppedTextPath.op(textPath, progressPath, Path.Op.DIFFERENCE);
Lines here and here.
I’ve written a Proof of Concept for this project called Diffre on Github. If you wanna test it out first, all the code is in this repo.

Default Alpha value of navigation bar in Lollipop

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

What does the number next to a color mean?

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.

making the background translucent

I want the background of my textView or Linear layout to be translucent. I have attached an image as an example of what I want to achieve.
translucent http://imagecdn3.maketecheasier.com/2011/03/kde-style-oxygen-transparent.jpg
I don't want to make the whole activity translucent but just a layout field in it. How can I get this?
See Translucent theme, descibed here:
http://developer.android.com/guide/topics/ui/themes.html
create an activity
set activity’s theme as “#android:style/Theme.Translucent” in AndroidManifest.xml
that’s all
Check this for more details.
For making the activity Completely transparent,
main.xml-
android:background="#android:color/transparent"
manifest.xml-
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
For making activity Translucent
#00FFFFFF - Full Transparency
#10FFFFFF - 90% Transparency
#20FFFFFF - 80% Transparency
#30FFFFFF - 70% Transparency
#40FFFFFF - 60% Transparency
#50FFFFFF - 50% Transparency
#60FFFFFF - 40% Transparency
#70FFFFFF - 30% Transparency
#80FFFFFF - 20% Transparency
#90FFFFFF - 10% Transparency
#99FFFFFF - 01% Transparency
Usage- in layout.xml,
android:background="20FFFFFF"
here "20" is transparency and "FFFFFF" is color
Get HTML color codes from http://html-color-codes.info/

android activity transparency

Is it possible to have your android activity run on top of the current running activity in a transparent mode so you can see through it the activity below it? If possible, can you have different levels of transparency?
You can apply a dialog theme or a translucent theme to your activity. More info here: Styles and Themes under the "Apply a theme to an Activity or application" section.
In manifest.xml
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
In Main.xml
android:background="#20FFFFFF"
#00FFFFFF - Full Transparency
#10FFFFFF - 90% Transparency
#20FFFFFF - 80% Transparency
#30FFFFFF - 70% Transparency
#40FFFFFF - 60% Transparency
#50FFFFFF - 50% Transparency
#60FFFFFF - 40% Transparency
#70FFFFFF - 30% Transparency
#80FFFFFF - 20% Transparency
#90FFFFFF - 10% Transparency
#99FFFFFF - 01% Transparency
20 is transparency level and FFFFFF is color

Categories

Resources