這很愚蠢,但如何把背景rgb在android上?Android上使用rgb的背景顏色(首選XML)?
我想把RGB顏色的背景,但我找不到如何做。
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background= ?
android:orientation="vertical" >
我已經做到了這種方式,但不工作
Color.rgb(200,0,0)
這很愚蠢,但如何把背景rgb在android上?Android上使用rgb的背景顏色(首選XML)?
我想把RGB顏色的背景,但我找不到如何做。
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background= ?
android:orientation="vertical" >
我已經做到了這種方式,但不工作
Color.rgb(200,0,0)
您可以設置RGB顏色與Android的HAX代碼,例如十六進制代碼#RRGGBB
下面是一些樣品的顏色:
Color Hex RGB Decimal Code
White #FFFFFF (255,255,255)
Red #FF0000 (255,0,0)
Lime #00FF00 (0,255,0)
Blue #0000FF (0,0,255)
例如你想設置您的視圖背景中爲藍色
android:background= "#0000FF"
定義您的色在Color res
文件夾中。
不知道如果你可以從XML使用RGB值。但我確信你可以從Java中完成這項工作。創建組件的一個實例並使用方法setBackgroundColor()
。使用如下:
yourComponent.setBackgroundColor(Color.rgb(200, 00, 00));
使用**#ff0000 **得到紅色 – Nabin
問題是我需要以RGB格式來做它@NabinKhadka –
爲什麼你需要在RGB中做任何強有力的理由? @Carlos Uriel聖地亞哥 – Kinjal