12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
编程知识 时间:2024-12-05 09:40:14
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
在Android中,可以通过以下方法设置按钮的背景颜色:在XML布局文件中设置按钮的背景颜色:<Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"andr
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
在Android中,可以通过以下方法设置按钮的背景颜色:
<Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Button"android:background="@color/colorAccent" />
其中,@color/colorAccent
是指向颜色资源文件中定义的颜色。
Button button = findViewById(R.id.button);button.setBackgroundColor(ContextCompat.getColor(this, R.color.colorAccent));
其中,R.color.colorAccent
是指向颜色资源文件中定义的颜色。
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19