按钮setBackgroundColor没有高亮效果 [英] Button setBackgroundColor no highlight effect
问题描述
当我创建了一个按钮,
Button myButton = new Button(this);
myButton.setText("Click Me!");
它创建了一个按钮,上点击,打开橙色表示点击。
it creates a button, that on click, turns "Orange" to indicate the click.
要当我添加按钮,
button.setBackgroundColor(Color.BLUE);
它创建了一个蓝色矩形,并且在点击不具有hightlight效果
It creates a blue rectangle, and on click does not have a hightlight effect.
我不介意矩形的一部分,我想,虽然得到橙色高亮效果。
I don't mind the rectangle part, I want to get the orange highlight effect though.
不能使用XML,需要为此在code。
Cannot use XML, need to do this in code.
感谢
推荐答案
有关设置背景颜色/图像,并具有点击高亮效果....你已经设置按钮的样式/主题。
For setting background color/image and having click highlight effect....you have set the style/theme for the button.
风格/主题包含了诸如集中/启动按钮的各种状态的颜色属性/残疾/等
The style/theme contains the color attributes for various states of button such as focused / enabled / disabled/ etc.
这篇关于按钮setBackgroundColor没有高亮效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!