android-color

How to darken a given color (int)

一世执手 提交于 2020-04-08 00:56:23
问题 I have a function that takes a given color and I would like it to darken the color (reduce its brightness by 20% or so). I can't figure out how to do this given just a color (int). What is the proper approach? public static int returnDarkerColor(int color){ int darkerColor = .... return darkerColor; } 回答1: A more Android way of doing it: public static int manipulateColor(int color, float factor) { int a = Color.alpha(color); int r = Math.round(Color.red(color) * factor); int g = Math.round

How to create a transparent Color Resource?

陌路散爱 提交于 2020-01-16 02:42:43
问题 I made a color resource, but I was wondering how to make it slightly transparent. I'm using it for an image button background. I'm trying to make it highlight like it automatically does when you have the default background. I've looked up some stuff but I just can't seem to find what I'm looking for, so I decided to ask on here. <?xml version="1.0" encoding="utf-8"?> <resources> <color name="white">#FFFFFF</color> </resources> That's literally all I have for the colour resource right now, but

How to create a transparent Color Resource?

扶醉桌前 提交于 2020-01-16 02:42:01
问题 I made a color resource, but I was wondering how to make it slightly transparent. I'm using it for an image button background. I'm trying to make it highlight like it automatically does when you have the default background. I've looked up some stuff but I just can't seem to find what I'm looking for, so I decided to ask on here. <?xml version="1.0" encoding="utf-8"?> <resources> <color name="white">#FFFFFF</color> </resources> That's literally all I have for the colour resource right now, but

Support library for text color behaviour of API 26?

霸气de小男生 提交于 2019-12-31 03:34:26
问题 API 26 introduces an advanced color calculation for ?textColorPrimary based on ?colorForeground . It makes use of states, primaryContentAlpha and disabledAlpha . sdk/platforms/android-26/data/res/color/text_color_primary.xml : <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:alpha="?attr/disabledAlpha" android:color="?attr/colorForeground"/> <item android:alpha="?attr/primaryContentAlpha"

Programmatically setting Button Background Drawable Color

隐身守侯 提交于 2019-12-25 06:59:04
问题 I have a drawable created beforehand which is a shape of rectangle but is fully transparent. Now I would like to assign this drawable to the Button in code but also set the Color of this drawable from transparent to some specific color like Orange etc. I have already tried setting the same using some other posts like - Drawable mDrawable = ContextCompat.getDrawable(this, R.drawable.square_transparent); mDrawable.setColorFilter( new PorterDuffColorFilter( Color.Orange, Mode.SRC_IN) ); but it

Change color of the drop down arrow of Spinner in XML

一笑奈何 提交于 2019-12-20 08:24:18
问题 As I wrote in my question, I want to change the color of the drop down arrow (the default arrow, not a custom arrow or something like that) of a Spinner in XML , but the problem is that I couldn't find anything to make reference to it from the XML . Is it possible? If yes, how can I change the color? Thanks in advance. 回答1: There are three ways to achieve that. 1. Through code: In your xml, make sure your spinner has an id. Let's say we have a spinner with id "spinner". In your code, add the

No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_light_text_pressed')

﹥>﹥吖頭↗ 提交于 2019-12-08 03:16:50
问题 I have built my app earlier using the Android studio 1.1. I had no problems then. After upgrading I am getting the following error when I try to rebuild my app. D:\-----\src\main\res\color\common_signin_btn_text_dark.xml Error:(4, 55) No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_dark_text_pressed'). Error:(5, 85) No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_dark_text_disabled'). Error:(6, 55)

No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_light_text_pressed')

不想你离开。 提交于 2019-12-06 14:39:23
I have built my app earlier using the Android studio 1.1. I had no problems then. After upgrading I am getting the following error when I try to rebuild my app. D:\-----\src\main\res\color\common_signin_btn_text_dark.xml Error:(4, 55) No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_dark_text_pressed'). Error:(5, 85) No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_dark_text_disabled'). Error:(6, 55) No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_dark_text

How can I get the primary color from my app theme?

狂风中的少年 提交于 2019-12-03 12:44:24
问题 In my Android java code, how can I reference the color "colorPrimary" set in my theme? I have the following theme definition: <!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"> <item name="colorPrimary">@color/myColor1</item> <item name="colorPrimaryDark">@color/myColor2</item> <item name="colorControlNormal">@color/myColor3</item> <item name="colorControlActivated">@color/myColor4</item> </style> I could reference the color resource directly (R.color.myColor1), but I

How to give the user the possibility to switch between different colors skin in your App

假如想象 提交于 2019-12-03 09:55:54
问题 I want to give the user the opportunity to select wich color skin will have the app. For example, i whould implement a black skin with black colours with different tonalities and also a white skin with withe tonalities. Which whould be the best approach to achieve this? For example i know that there is a colors.xml file in Android that should contain the colours of your app. Whould be a way to have two colors files or something and to use one or other depending of user selection? Maybe a