【问题标题】:Android- How to change the colour of a button in xml?Android-如何更改xml中按钮的颜色?
【发布时间】:2014-05-03 19:37:25
【问题描述】:

如何更改按钮的颜色?实际的按钮不是按钮的文本。

我想把它改成绿色。 (#00FF00) 我也想让文字保持黑色。

按钮代码:

<Button
        android:id="@+id/btnGoPractice2"
        android:layout_width="85dp"
        android:layout_height="50dp"
        android:layout_gravity="center"
        android:text="Submit" 
        android:paddingBottom="10dp"/>

【问题讨论】:

  • android:background="#00ff00"

标签: android button


【解决方案1】:

只需在按钮标签内执行 android:background="color hex value"。

例如:

 android:background="#00FF00" // For Button Background
 android:textColor="#000000"  // For button Text Color

希望这会有所帮助.. :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-22
    相关资源
    最近更新 更多