【问题标题】:Button color changed due to background color按钮颜色因背景颜色而改变
【发布时间】:2015-10-25 13:34:26
【问题描述】:

我使用 android:background 更改了我的活动的背景颜色。背景颜色会发生变化,但按钮背景的颜色也会发生变化。我想保留具有默认背景和属性的按钮。

按钮如图所示。

Activity的XML文件在下面

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:background="#116493">

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="?android:attr/buttonStyleSmall"
        android:text="Button" />

</LinearLayout>

【问题讨论】:

  • 只需设置按钮的背景。问题解决了
  • @Nimit,很高兴听到。

标签: android android-layout android-activity


【解决方案1】:

@Nimit Aggarwal:请更新您的主题设置。删除 style="?android:attr/buttonStyleSmall" 。 加button

 <Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/your_image"
    android:text="Button" />

如需演示,请关注Android ImageButton selector example

【讨论】:

  • 更新主题设置以获取带背景的默认按钮? @IntelliJ 阿米娅
  • 默认按钮应用哪个主题?
猜你喜欢
  • 1970-01-01
  • 2017-03-25
  • 2015-06-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-09
相关资源
最近更新 更多