是的,setBackgroundColor()
方法可以用于所有视图(View)
例如,如果你想为一个按钮设置背景颜色,你可以这样做:
Button button = findViewById(R.id.my_button);
button.setBackgroundColor(Color.parseColor("#FFC107"));
这将把ID为my_button
的按钮的背景颜色设置为黄色。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:android setbackgroundcolor 能用图片吗