[英]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.