The Color editor.From the drop-down menu in the top-right of the Resources dialog, clickAdd new resource New color Value. The Resources dialog displays an editableright pane with a blank Name field so you can enter a name for your custom color. Create the custom color as follows. The steps correspond to the callouts in figure 1. Type a name for your new color value in the empty Name field.
Android Studio includes a visual assistant called Theme Editor that helps you. The Theme Editor allows you to create new themes, modify existing ones,.
No spaces or specialcharacters allowed in the name. Underscores and numbers are okay. Color scale, Custom color field, and dropper:.
On the color scale, click the color you want. The color displaysin the Custom color field. You can use the dropper to the left of theCustom color field to select a color. Click thedropper, andthen clicksomething visible anywhere on your computer screen.
The color in theCustom color field changes to the color you selected. Just below the Custom color field, use the editable fields and drop-down menuon the left to specify an RGB, HSB, or ARGB colorby numeric values. The HEX equivalent ofyour color displays in the editable field to the far right. To set the color opacity and hue, move the sliders below the color scale. Select one of the available predefined color squares. The color displays in theCustom Color field and the name changes to the name of the color you selected. Click OK to save your settings.
The Resources dialog closes and returns youto the Theme Editor.Modify a colorYou can modify any editable color. If a color is editable, you see editable color, hue, opacity,name field, and device configuration fields.
See if youwant to know why some fields are editable and others are not. Adjust the settings. Click OK.Match material colorIf you have defined or modified a custom project color, you canensure that the color matches the closestby clicking CLOSEST MATERIALCOLOR, located next to Custom color. Android Studio changes the color and opacity valuesof the color you picked to the material color most like it, and replaces Custom color withthe name of the color from the material palette.Note: The CLOSEST MATERIAL COLOR feature is visible only when thecolor is not already a material color.Viewing state lists and colorsThe Theme Editor allows you to previewTo do so, open the Resources dialog byclicking on the color set square next to the name of an editable state list resource. TheResources dialog displays a list of states, such as Selected, and thecolor value associated with the state. Click the color for a state to choose a differentcolor value.To more fully control the states themselves, you can directly view and edit theirproperties in the XML file that defines them.
For more information, see thedocumentation for theclass.Device-specific configurationsWhen a color is editable, you can chooseconfigurations for your app to support. Performthe following steps to do so:. Open the Resources dialog.
For information about how to open theResources dialog, see. Select a Project color, and then in the bottom of the right pane, click toexpand Device Configuration, revealingthe source set and name of the XML file containing theresource, and a list of configuration-specific directories in which toplace that file.
If necessary, change the XML file name. Check the boxes next to the directories corresponding to thedevice-specific configurations you wish to support. Any configurationfor which you do not specify a directory defaults to using thevalues directory.For more information about the relationshipbetween directory names and configurations, see.
For more information aboutsupported directory names, see.Content and code samples on this page are subject to the licenses described in the. Java is a registered trademark of Oracle and/or its affiliates.