[我以编程方式创建了android按钮,然后将这些按钮放在TableRow中,一切正常,但是当我更改backgroudColor时,彩色按钮不像没有颜色时那样尊重大小:
我的代码是:
val btn = Button(this)
btn.isEnabled = false
btn.setBackgroundColor(Color.RED)
btn.layoutParams = TableRow.LayoutParams(150, 150)
当我不使用setBackgroundColor
时大小正确。
我不明白为什么更改尺寸,有没有办法只更改按钮的默认灰色,而无需更改尺寸。
btn.setBackgroundColor(R.color.RED)