android: textColor -> wartość RGB nie zczytana

0

Hej,
mam taki problem z aplikacją na android, mianowicie chcę ustawić kolor tekstu w TextView na R:238 G:83 B:107, z dokumentacji wynika że dostępne wartości to: RGB, ARGB, RRGGBB, AARRGGBB.

Aby ustawić stałą koloru robię to tak że wchodzę w res/values/ klikam dwa razy na "strings" i dodaję nowy element typu Color. Tam wpisuję #23883107, ale to nie działa :(

Jak mam poprawnie to ustawić?

0

A widziałeś, próbowałeś?
http://stackoverflow.com/a/4602929
http://developer.android.com/reference/android/graphics/Color.html

Color Class

public static int parseColor (String colorString)
Added in API level 1
Parse the color string, and return the corresponding color-int. If the string cannot be parsed, throws an IllegalArgumentException exception. Supported formats are: #RRGGBB #AARRGGBB 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray', 'grey', 'lightgrey', 'darkgrey', 'aqua', 'fuschia', 'lime', 'maroon', 'navy', 'olive', 'purple', 'silver', 'teal'

public static int rgb (int red, int green, int blue)
Added in API level 1
Return a color-int from red, green, blue components. The alpha component is implicity 255 (fully opaque). 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.

Parameters
red Red component [0..255] of the color
green Green component [0..255] of the color
blue Blue component [0..255] of the color

0

Widziałem, ale ja nie chcę robić tego w kodzie tylko w layout-ach.

0

Problem polega na tym że u mnie jest R:238, G:83, B:107, to w sumie daje 8 cyfr...a z tej dokumentacji wynika że mogę mieć dla RGB tylko 6... próbowałem to zmienić i dostałem takie coś: EE006B, ale ten kolor nie jest poprawnie czytany przez androida (jest popielaty, a poprawny to odcień różu).

EDIT:
działa tak:

 android:textColor="#EE536B" 
1

Dla potomnosci:

#!/usr/bin/env python

Red = int(raw_input("Czerwony: "))
Green = int(raw_input("Zielony: "))
Blue = int(raw_input("Niebieski: "))

print "%X%X%X\n" % (Red,Green,Blue)
0

kolory w androidzie na heksagonalnych kolorach :P

przydatny link http://www.javascripter.net/faq/rgbtohex.htm

1 użytkowników online, w tym zalogowanych: 0, gości: 1