简体   繁体   中英

color-palette or third party plugin in order to set colors in eclipse

Is there easy way to manipulate colors in android ?

  • In dot.net we have color palette to change the color of objects(button-background,text-color.. etc)

  • similarly is there any color palette/or/-any-plugins in object browser of eclipse IDE at design time

Note :: I am aware of changing the color by adding color codes in styles.xml and referencing it in layout.xml

You can do this in some cases directly,

eg in TextView you can change the Text Color by applying this statement in

Java code

 textView1.setTextColor(Color.Red);

for other objects like buttons etc. you can not change their Color Directly like C# .

You have to create different .xml file and then you will store this .xml file inb drawable folder, in your activity_main(where button is created in your layout file) you have to make reference eg

<Button
    android:background="@drawable/red_button" />

now the colored button .xml file located in

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>

Check this Link for more Details

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM