android - 如何更改Android中按钮的文本背景颜色?

标签 android android-button

我找了很多,但没有找到我想要的。我打算做的是更改按钮上文本的背景颜色。我对单击时更改颜色不感兴趣。我只想更改按钮上文本的背景。谢谢。

编辑: 这是一个样本。如果可能的话,我想更改黑色。

http://i.imgur.com/B8tYnEN.png

最佳答案

使用它来设置按钮的文本颜色:

setTextColor(getResources().getColor(R.color.white));

android:textColor="@color/white"

使用它来设置按钮的背景:

setBackgroundResource(R.drawable.button_img);

android:background="@drawable/button_img"

android:background="@color/blue"

关于android - 如何更改Android中按钮的文本背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18998718/

相关文章:

Android:暂时连接到WiFi网络?

android - 如何在 chrome 应用程序中使用自动完成功能?

android - 如何在android中读取谷歌地图的kmz文件

安卓 : Decreasing size of the Button

android - 我的按钮总是用 performClick 调用两次

安卓 XML : drawing StackOverflow's GraphicDesign's diamond/rhombus button with diamond/rhombus borders

android - 用于在 Google PlayStore 上获取应用程序版本的官方 API

android - 通过 android 中的 Intent 将视频分享到 viber 不起作用

java - 无法解析符号 'setOnClickListener' - Android Studio

android - 覆盖按钮不起作用的文本颜色