为什么更改默认按钮的颜色使其看起来像矩形?我不想为此使用自定义背景图像。 我想在少数情况下以编程方式执行此操作,在这些情况下我会更改屏幕上许多小按钮的颜色。 谁能给出解决方案?
附言==> 阅读本文似乎没有解决方法 http://groups.google.com/group/android-beginners/browse_thread/thread/e1313e2c98e9c52b
或者有没有?
最佳答案
改变颜色:
Drawable d = findViewById(R.id.button_name).getBackground();
PorterDuffColorFilter filter = new PorterDuffColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);
d.setColorFilter(filter);
去除颜色:
Drawable d = findViewById(R.id.button_name).getBackground();
findViewById(R.id.button_name).invalidateDrawable(d);
d.clearColorFilter();
关于android - 为什么更改默认按钮的颜色使其在 Android 中看起来像矩形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2770689/