Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should be the color of the Ripple, colorPrimary or colorAccent? (Material Design)

I have reading Material Design Guidelines but I don't know what should be the color of the Ripple if it isn't black (with alpha).

For example, I have an app with colorPrimary = blue, and colorAccent = red. Actually I am using the colorAccent (with alpha), I should use colorPrimary (with alpha) if I want a color different of black to the ripple?

I checked all app of Google but they never use ripples with color.

An image like I have now:

ripple

like image 637
JavierSegoviaCordoba Avatar asked Feb 12 '15 17:02

JavierSegoviaCordoba


People also ask

What is the default ripple color android?

android:colorControlHighlight will give the ripple the same color as the built-in ripples in your app. If you don't like the default grey, you can specify what color you want android:colorControlHighlight to be in your theme.

What is colorPrimary and colorPrimaryVariant?

colorPrimary and colorSecondary represent the colors of your brand. colorPrimaryVariant and colorSecondaryVariant are lighter or darker shades of your brand colors. colorSurface is used for “sheets” of material (like cards and bottom sheets)

How do I change the ripple color in material UI?

If you want the ripple and label to be different colors, you have to override the label color separately. import MUIButton from 'material-ui/Button'; import {withStyles} from 'material-ui/styles'; const Button = (props) => { return <MUIButton className={props.

What is secondary brand color in android Studio?

The secondary color provides more ways to accent and distinguish your product. The secondary variant color is used to distinguish two elements of the app using the secondary color. The surface color is used on surfaces of components, such as cards, sheets and menus.


2 Answers

Use 26% alpha for colored ripples.

Android L doesn't support theme attributes in color state lists and the <ripple> element doesn't have an alpha channel, but for bounded ripples you can do something like:

<ripple xmlns:android="http://schemas.android.com/apk/res/android"         android:color="?android:attr/colorAccent">     <item android:id="@android:id/mask">         <color android:color="#42ffffff" />     </item> </ripple> 

This won't work for an unbounded ripple. Alternatively, since you know your own accent color, you can either define a 26% alpha version or use a color state list. Either of these will work fine for an unbounded ripple.

<ripple xmlns:android="http://schemas.android.com/apk/res/android"         android:color="@color/accent_26" /> 

res/values/colors.xml:

<resources>     ...     <color name="accent">#ff33b5e5</color>     <color name="accent_alpha26">#4233b5e5</color> </resources> 

res/color/accent_alpha26.xml:

<selector xmlns:android="http://schemas.android.com/apk/res/android">     <item android:color="@color/accent"           android:alpha="0.26" /> </selector> 
like image 154
alanv Avatar answered Oct 11 '22 05:10

alanv


Here is what you are looking for:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">    ...    <item name="colorControlHighlight">@color/ripple_material_dark</item>    ... </style> 
like image 33
i.shadrin Avatar answered Oct 11 '22 07:10

i.shadrin