[英]color-palette or third party plugin in order to set colors in eclipse
在dot.net中,我們具有用於更改對象顏色的調色板(按鈕背景,文本顏色等)。
類似地,在設計時eclipse IDE的對象瀏覽器中是否有任何調色板/或/-任何插件
注意 :::我知道通過在styles.xml中添加顏色代碼並在layout.xml中引用它來更改顏色
在某些情況下,您可以直接執行此操作,
例如在TextView中,您可以通過在
Java代碼
textView1.setTextColor(Color.Red);
對於其他對象(例如按鈕等),您不能像C#一樣直接更改其顏色。
您必須創建另一個.xml文件,然后將該.xml文件存儲在drawable文件夾中,在您的activity_main(where button is created in your layout file) you have to make reference
例如
<Button
android:background="@drawable/red_button" />
現在彩色按鈕.xml文件位於
res / drawable / red_button.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/red_button_pressed" />
<item android:state_focused="true" android:drawable="@drawable/red_button_focus" />
<item android:drawable="@drawable/red_button_rest" />
</selector>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.